linux 磁盤掛載

一、運行 fdisk -l 命令查看數據盤。node

# fdisk -l

找到要掛載的磁盤:ide

二、運行 fdisk /dev/vdd,對數據盤進行分區。根據提示,依次輸入 n,p,1,兩次回車,wq,分區就開始了。ui

root@d049:~# fdisk /dev/vdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x78636cd5.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): 
Using default value 20971519

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
root@d049:~#

運行 fdisk -l 命令,查看新的分區。新分區 xvdb1 已經建立好。以下面示例中的/dev/xvdb1。code

# fdisk -l

三、格式化orm

運行mkfs.ext3 /dev/vdd1對新分區進行格式化。ip

root@d049:~# mkfs.ext3 /dev/vdd1
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621184 blocks
131059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

root@d049:~#

四、運行 echo /dev/vdd1 /mnt ext3 defaults 0 0 >> /etc/fstab 寫入新分區信息。ci

完成後,能夠使用 cat /etc/fstab 命令查看。rem

root@d049:~# echo /dev/vdd1 /mnt ext3 defaults 0 0 >> /etc/fstab
root@d049:~# cat /etc/fstab
LABEL=cloudimg-rootfs	/	 ext4	defaults	0 0
/dev/vdb	none	swap	sw,comment=cloudconfig	0	0
/dev/vdc1 /mnt ext3 defaults 0 0
/dev/vdd1 /mnt ext3 defaults 0 0
root@d049:~#

五、掛載:運行 mount /dev/vdd1 /mnt  (能夠選擇掛載點)掛載新分區,而後執行 df -h 查看分區。it

root@d049a:~# mount /dev/vdd1 /root/
root@d049a:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            988M   12K  988M   1% /dev
tmpfs           201M  388K  200M   1% /run
/dev/vda1        15G  1.9G   12G  14% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none           1001M     0 1001M   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/vdc1        20G   45M   19G   1% /mnt
/dev/vdd1       9.8G   23M  9.2G   1% /root
root@d049:~#

六、解綁:umount -l /dev/vdd1io

root@d049a:~# umount -l /dev/vdd1
root@d049a:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            988M   12K  988M   1% /dev
tmpfs           201M  388K  200M   1% /run
/dev/vda1        15G  1.9G   12G  14% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none           1001M     0 1001M   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/vdc1        20G   45M   19G   1% /mnt
root@d049a:~#
相關文章
相關標籤/搜索