linux 磁盘管理 fdisk分区
1.fdisk分区
[root@xiao ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0006e14a Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 281 2048000 82 Linux swap / Solaris Partition 2 does not end on cylinder boundary. /dev/sda3 281 2611 18717696 83 Linux Disk /dev/sdb: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 [root@xiao ~]# fdisk -cu /dev/sdb m # 帮助 p # 查看分区表 q # 退出 ==Command (m for help): p # 查看分区表 Disk /dev/sdb: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0x7a5948ad Device Boot Start End Blocks Id System Command (m for help): n # 创建 Command action e extended p primary partition (1-4) p # 主分区 Partition number (1-4): 1 # 分区1 First sector (2048-2097151, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +10M # 分区10M Command (m for help): P # 查看分区 Disk /dev/sdb: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0x7a5948ad Device Boot Start End Blocks Id System /dev/sdb1 2048 22527 10240 83 Linux Command (m for help): n # 创建分区 Command action e extended p primary partition (1-4) e 扩展分区 Partition number (1-4): 2 # 分区2 First sector (22528-2097151, default 22528): Using default value 22528 Last sector, +sectors or +size{K,M,G} (22528-2097151, default 2097151): Using default value 2097151 Command (m for help): p # 查看分区 Disk /dev/sdb: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0xa2047beb Device Boot Start End Blocks Id System /dev/sdb1 2048 22527 10240 83 Linux /dev/sdb2 22528 2097151 1037312 5 Extended Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First sector (24576-2097151, default 24576): Using default value 24576 Last sector, +sectors or +size{K,M,G} (24576-2097151, default 2097151): +20M Command (m for help): P Disk /dev/sdb: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0xa2047beb Device Boot Start End Blocks Id System /dev/sdb1 2048 22527 10240 83 Linux /dev/sdb2 22528 2097151 1037312 5 Extended /dev/sdb5 24576 65535 20480 83 Linux Command (m for help): t # 调整分区系统 Partition number (1-8): 8 Hex code (type L to list codes): L 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx 5 Extended 42 SFS 86 NTFS volume set da Non-FS data 6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility 8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt 9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary 16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS 17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT 1e Hidden W95 FAT1 Hex code (type L to list codes): 8e Changed system type of partition 8 to 8e (Linux LVM) Command (m for help): p Disk /dev/sdb: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders, total 2097152 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 identifier: 0xa2047beb Device Boot Start End Blocks Id System /dev/sdb1 2048 22527 10240 83 Linux /dev/sdb2 22528 2097151 1037312 5 Extended /dev/sdb5 24576 65535 20480 83 Linux /dev/sdb6 67584 129023 30720 83 Linux /dev/sdb7 131072 212991 40960 83 Linux /dev/sdb8 215040 2097151 941056 8e Linux LVM Command (m for help): w # 保存
2.格式并挂载分区
[root@xiao ~]# partprobe /dev/sdb 通知系统内核分区表的变化,不然内核不知道分区(或重启系统) [root@xiao ~]# mkfs.ext4 /dev/sdb1 格式分区,并指定分区系统 [root@xiao ~]# tune2fs -c -1 /dev/sdb1 不让磁盘检查, [root@xiao ~]# mount /dev/sdb1 /data 挂载分区 [root@xiao ~]# blkid # 查看UUID /dev/sda2: UUID="e9174783-c9fc-4f3c-9bbc-ccce5a631270" TYPE="xfs" /dev/sda3: UUID="4pNVYs-z2Ga-dlKl-3of8-t7ta-hNfo-H5X6dT" TYPE="LVM2_member" /dev/sda4: UUID="7d323225-b8aa-4928-a96a-97a71290eb5b" TYPE="xfs" /dev/mapper/centos00-root: UUID="966398e5-a0c7-4076-96dc-860ee003dfde" TYPE="xfs" /dev/mapper/centos00-swap: UUID="1018b2ba-5dbf-487c-be0a-f4817d19e6c3" TYPE="swap" [root@xiao ~]# vim /etc/fstab # 开机自动挂载,挂载UUID # # /etc/fstab # Created by anaconda on Tue Jun 14 21:53:06 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=83439064-1811-42e6-9a80-206de7572cd3 / ext4 defaults 1 1 UUID=f929bf33-ff94-43c4-b0cf-9de68915b2ed /boot ext4 defaults 1 2 UUID=b9d84bde-e18c-4241-9459-aa0910fe8e51 swap swap defaults 0 0 UUID=7d323225-b8aa-4928-a96a-97a71290eb5b /data ext4 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

浙公网安备 33010602011771号