購買LINUX系統(tǒng)VPS及云服務(wù)器產(chǎn)品后,由于用戶選擇的空間大小不同,后臺云存儲分配的實際存儲盤符也會發(fā)生相應(yīng)的變化,所以這時候需要用戶自行做掛載處理,處理步驟如下(//以及后面的都是注釋,不用輸入):
[root@~]# df -h //檢查當前掛載磁盤
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 14G 3.4G 9.4G 27% /
/dev/sda1 99M 12M 83M 13% /boot
tmpfs 252M 0 252M 0% /dev/shm
[root@~]#
[root@~]# fdisk -l //檢查當前分區(qū),下面紅色的sbd是沒有分區(qū)的,需要下一步操作
Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 144 1052257+ 82 Linux swap / Solaris
/dev/sda3 145 1958 14570955 83 Linux
Disk /dev/sdb: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn’t contain a valid partition table
[root@~]#
這時會看到有16G的sdb(Disk /dev/sdb: 16.1 GB)沒有分配,可以按照下面的方法繼續(xù)分配,由于實際分配的不一定是sdb(有可能是hdc或hdd等),下面的操作都是以系統(tǒng)顯示為sdb來做下面的操作。
2、 對sdb做分區(qū):
[root@ ~]# fdisk /dev/sdb //對sdb做分區(qū)
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.
The number of cylinders for this disk is set to 1958.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n //繼續(xù)下一步輸入n
Command action
e extended
p primary partition (1-4)p //輸入p
Partition number (1-4): //輸入1
First cylinder (1-1958, default 1): //回車
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1958, default 1958): //回車
Using default value 1958
Command (m for help): w //輸入w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
You have mail in /var/spool/mail/root
[root@ ~]#
3、 格式化:
[root@ ~]# fdisk -l //確認剛分區(qū)的是否存在(下面紅色部分就是我們剛分區(qū)并要繼續(xù)格式化的磁盤點)
Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 144 1052257+ 82 Linux swap / Solaris
/dev/sda3 145 1958 14570955 83 Linux
Disk /dev/sdb: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1958 15727603+ 83 Linux
[root@ ~]#
[root@~]# mkfs.ext3 /dev/sdb1 //格式化sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1966080 inodes, 3931900 blocks
196595 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4026531840
120 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@~]#
4、 掛載分區(qū):
[root@~]# mkdir /user1 //創(chuàng)建需要掛載的分區(qū)目錄,可以自定義
[root@~]# mount /dev/sdb1 /user1/ //掛載剛創(chuàng)建的目錄
[root@~]# df -h //確定是否掛載成功,和第一步比較
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 14G 3.5G 9.4G 27% /
/dev/sda1 99M 12M 83M 13% /boot
tmpfs 252M 0 252M 0% /dev/shm
/dev/sdb1 15G 166M 14G 2% /user1
[root@~]#
5、 配置自動掛載(重啟服務(wù)器會后自動加載上):
[root@ ~]# cat /etc/fstab //查看當前加載情況
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
[root@ ~]#vi /etc/fstab //編輯fatab文件并加入下面一行
/dev/sdb1 /user1 ext3 defaults,noatime 0 0
[root@SZNC-DB-4120 ~]# cat /etc/fstab //確認是否已加入(紅色部分)
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
/dev/sdb1 /user1 ext3 defaults,noatime 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 LABEL=SWAP-sda2 swap swap defaults 0 0 [root@SZNC-DB-4120 ~]#