fdisk新建分区:
[[email protected] ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280bytes Sector size (logical/physical): 512 bytes /512 bytes I/O size (minimum/optimal): 512 bytes / 512bytes Disk identifier: 0x000e7df7 Device Boot Start End Blocks Id System /dev/sda1 * 1 511 4096000 83 Linux Partition 1 does not end on cylinderboundary. /dev/sda2 511 1020 4096000 83 Linux Partition 2 does not end on cylinderboundary. /dev/sda3 1020 1275 2048000 82 Linux swap / Solaris /dev/sda4 1275 2611 10730496 5 Extended /dev/sda5 1276 2611 10729472 83 Linux Disk /dev/sdb: 21.5GB, 21474836480 bytes 255 heads, 63sectors/track, 2610 cylinders Units = cylinders of16065 * 512 = 8225280 bytes Sector size(logical/physical): 512 bytes / 512 bytes I/O size(minimum/optimal): 512 bytes / 512 bytes Disk identifier:0x00000000 [[email protected] ~]# fdisk /dev/sdb 开始分区 Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with diskidentifier 0x6811b6b9. Changes will remain in memory only, untilyou decide to write them. After that, of course, the previous contentwon‘t be recoverable. Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated.It‘s strongly recommended to switch off the mode (command ‘c‘) and change display units to sectors (command ‘u‘). Command (m for help): m #查看帮助 Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibilityflag d delete a partition l list known partition types m print this menu n add a new partition #添加一个新分区 o create a new empty DOSpartition table p print the partition table #查看当前分区情况 q quit without saving changes s create a new empty Sundisklabel 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 (expertsonly) Command (m for help): n #添加一个新分区 Command action e extended p primary partition (1-4) p #主分区 Partition number (1-4): 1 #分区号 First cylinder (1-2610, default 1): 1 #柱面 Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +4G #分配大小(不以柱面方式) Command (m for help): p #查看一下 Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280bytes Sector size (logical/physical): 512 bytes /512 bytes I/O size (minimum/optimal): 512 bytes / 512bytes Disk identifier: 0x6811b6b9 Device Boot Start End Blocks Id System /dev/sdb1 1 523 4200966 83 Linux成功! Command (m for help): n #继续添加分区 Command action e extended p primary partition (1-4) e #扩展分区 Partition number (1-4): 2 #分区号 First cylinder (524-2610, default 524): #默认起始柱面-回车 Using default value 524 Last cylinder, +cylinders or +size{K,M,G}(524-2610, default 2610): #默认结束柱面-回车 Using default value 2610 Command (m for help): p #查看一下 Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280bytes Sector size (logical/physical): 512 bytes /512 bytes I/O size (minimum/optimal): 512 bytes / 512bytes Disk identifier: 0x6811b6b9 Device Boot Start End Blocks Id System /dev/sdb1 1 523 4200966 83 Linux /dev/sdb2 524 2610 16763827+ 5 Extended #扩展分区成功! Command (m for help): n #继续分逻辑分区 Command action l logical (5 or over) p primary partition (1-4) l #选逻辑分区 First cylinder (524-2610, default 524): #默认起始柱面-回车 Using default value 524 Last cylinder, +cylinders or +size{K,M,G}(524-2610, default 2610): #默认结束柱面-回车 Using default value 2610 Command (m for help): p #查看一下 Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280bytes Sector size (logical/physical): 512 bytes /512 bytes I/O size (minimum/optimal): 512 bytes / 512bytes Disk identifier: 0x6811b6b9 Device Boot Start End Blocks Id System /dev/sdb1 1 523 4200966 83 Linux /dev/sdb2 524 2610 16763827+ 5 Extended /dev/sdb5 524 2610 16763796 83 Linux #成功! Command (m for help): w #保存 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [[email protected] ~]# partprobe #重新读取分区表信息 [[email protected] ~]# mkfs -t ext4 /dev/sdb1 #格式化 [[email protected] ~]# mkdir /disk1 /disk5 #创建两个挂载点 [[email protected] ~]# mount /dev/sdb1 /disk1 #挂载 [[email protected] ~]# mount /dev/sdb5 /disk5 #挂载
开机自动挂载:
[[email protected] ~]# dumpe2fs /dev/sdb1 #查看分区UUID dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: 968fc705-506d-4977-a469-32be93467a97 [[email protected] ~]# dumpe2fs /dev/sdb5 |more dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: 987dd564-5d12-4d0b-9706-c5bdf860e927 # # /etc/fstab # Created by anaconda on Wed Jan 6 23:44:24 2016 # # Accessible filesystems, by reference, aremaintained under ‘/dev/disk‘ # See man pages fstab(5), findfs(8),mount(8) and/or blkid(8) for more info [[email protected] ~]# vim /etc/fstab # UUID=b943e84c-2d74-4098-85ed-096353ff1815/ ext4 defaults 1 1 UUID=4f4b30ad-e3e4-45c3-bb60-6f6c0dd8cd62/boot ext4 defaults 1 2 UUID=41c2e8a6-10f0-4a10-b1a8-fe8db32ce708/home ext4 defaults 1 2 UUID=289dd6bc-687b-48e9-9d10-e34aa360228fswap swap defaults 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 UUID=968fc705-506d-4977-a469-32be93467a97/disk1 ext4 defaults 12 /dev/sdb5 /disk5 ext4 defaults 1 2 [[email protected] ~]# mount –a #测试一下,所有分区按照配置文件/etc/fstab 重新挂载一次 /etc/fstab
文件错误时修复:
[[email protected] ~]# mount -o remount,rw / #重新将/挂载成读写权限,只用于 /etc/fstab 文件错误修复时。
时间: 2024-10-06 04:47:22