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:~#
相关文章
相关标签/搜索