磁盘挂载操作步骤 - smile0821/learngit GitHub Wiki
[root@WUH1000144639 ~]# fdisk -l
Disk /dev/xvda: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x00089842
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 75497471 37747712 83 Linux /dev/xvda2 75497472 83886079 4194304 82 Linux swap / Solaris
Disk /dev/xvde: 193.3 GB, 193273528320 bytes, 377487360 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@WUH1000144639 ~]# fdisk /dev/xvde #进入磁盘 Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xf5352280.
Command (m for help): m Command action a toggle a bootable flag #设定可启动标记 b edit bsd disklabel c toggle the dos compatibility flag d delete a partition #删除一个分区 g create a new empty GPT partition table #各分区类型所对应的ID G create an IRIX (SGI) partition table #菜单 l list known partition types #添加一个分区 m print this menu n add a new partition o create a new empty DOS partition table p print the partition table #显示该磁盘下的当前分区信息 q quit without saving changes #不保存退出 s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit #保存退出 x extra functionality (experts only)
Command (m for help): p #打印当前分区信息,可以看到当前并没有分区
Disk /dev/xvde: 193.3 GB, 193273528320 bytes, 377487360 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xf5352280
Device Boot Start End Blocks Id System
Command (m for help): n #创建一个新的分区
Partition type:
p primary (0 primary, 0 extended, 4 free) #输入p为创建逻辑分区
e extended #输入e为创建扩展分区
Select (default p): p
Partition number (1-4, default 1): 1 #划分逻辑分区
First sector (2048-377487359, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-377487359, default 377487359):
Using default value 377487359
Partition 1 of type Linux and of size 180 GiB is set
Command (m for help): p #再次查看可以看到该磁盘已经有1个分区了
Disk /dev/xvde: 193.3 GB, 193273528320 bytes, 377487360 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xf5352280 Device Boot Start End Blocks Id System /dev/xvde1 2048 377487359 188742656 83 Linux
Command (m for help): w #保存分区 The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
[root@WUH1000144639 ~]# fdisk -l Disk /dev/xvda: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x00089842 Device Boot Start End Blocks Id System /dev/xvda1 * 2048 75497471 37747712 83 Linux /dev/xvda2 75497472 83886079 4194304 82 Linux swap / Solaris
Disk /dev/xvde: 193.3 GB, 193273528320 bytes, 377487360 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xf5352280 Device Boot Start End Blocks Id System /dev/xvde1 2048 377487359 188742656 83 Linux
[root@WUH1000144639 ~]# mkfs.ext3 /dev/xvde1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux出的 Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 11796480 inodes, 47185664 blocks 2359283 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 1440 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, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@WUH1000144639 ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/xvda1 36G 4.7G 29G 14% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.6G 84K 1.6G 1% /dev/shm tmpfs 1.6G 153M 1.5G 10% /run tmpfs 1.6G 0 1.6G 0% /sys/fs/cgroup tmpfs 327M 16K 327M 1% /run/user/988 tmpfs 327M 0 327M 0% /run/user/0
[root@WUH1000144639 ~]# cd / [root@WUH1000144639 /]# mkdir u01 [root@WUH1000144639 u01]# mount /dev/xvde1 /u01 [root@WUH1000144639 u01]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/xvda1 36G 4.7G 29G 14% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.6G 84K 1.6G 1% /dev/shm tmpfs 1.6G 153M 1.5G 10% /run tmpfs 1.6G 0 1.6G 0% /sys/fs/cgroup tmpfs 327M 16K 327M 1% /run/user/988 tmpfs 327M 0 327M 0% /run/user/0 /dev/xvde1 178G 60M 168G 1% /u01