磁盤的分區
主分區與擴展分區最多可以有4個(分區表64字節,每分區占16字節);
擴展分區最多只能有一個;
邏輯分區是由擴展分區持續分出來的分區;
能夠被格式化后作為數據訪問的分區為主要分區與邏輯分區,擴展分區無法格式化;
邏輯分區的數量以操作系統而不同,在Linux系統中,IDE硬盤最多有59個邏輯分區(5-63),SATA硬盤則有11個邏輯分區(5-15);
各接口的磁盤在Linux中的文件名分別為
/dev/sd[a-p][1-15]:為SCSI,SATA,USB,Flash等接口的磁盤文件名;
/dev/hd[a-d][1-63]:為IDE接口的磁盤文件名;
文件系統分類
Windows :NTFS、FAT32
Linux:ext2、ext3、ext4、xfs、reiserfs、nfs、iso9660、jfs、brtfs
小結:通過以上內容,我們簡單了解了磁盤的組成、分區、接口的磁盤命名及文件系統的分類。下面我們來具體看下磁盤分區、格式化及磁盤掛載所使用到的命令。
[root@ti0203a400-1401 /]# fdisk -l //查看磁盤
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x000152be
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 5125 40960000 83 Linux
/dev/sda3 5125 5380 2048000 82 Linux swap / Solaris
[root@ti0203a400-1401 /]# fdisk /dev/sda //開始創建磁盤分區
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): p //顯示分區表
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x000152be
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 5125 40960000 83 Linux
/dev/sda3 5125 5380 2048000 82 Linux swap / Solaris
Command (m for help): n //新建一個分區
Command action
e extended
p primary partition (1-4)
p //創建主分區
Selected partition 4 //分區號
First cylinder (5380-6527, default 5380): //(開始柱面-可默認)
Using default value 5380
Last cylinder, +cylinders or +size{K,M,G} (5380-6527, default 6527): +5G //磁盤大小
Command (m for help): p //顯示分區表
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x000152be
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 5125 40960000 83 Linux
/dev/sda3 5125 5380 2048000 82 Linux swap / Solaris
/dev/sda4 5380 6033 5246248+ 83 Linux
Command (m for help): w //保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@ti0203a400-1401 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 39G 3.3G 34G 9% /
tmpfs 491M 92K 491M 1% /dev/shm
/dev/sda1 190M 55M 126M 31% /boot
[root@ti0203a400-1401 /]# cat /proc/partitions //查看分區表是否加載
major minor #blocks name
8 0 52428800 sda
8 1 204800 sda1
8 2 40960000 sda2
8 3 2048000 sda3
8 4 5246248 sda4 //如果沒有加載就執行下面指令重新讀取加載
[root@ti0203a400-1401 /]# partx -a /dev/sda // RHEL6讓內核重新讀取硬盤分區表:
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
[root@ti0203a400-1401 /]# mkfs -t ext4 /dev/sda4 //格式化新建磁盤
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
328000 inodes, 1311562 blocks
65578 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1346371584
41 block groups
32768 blocks per group, 32768 fragments per group
8000 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks):
done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@ti0203a400-1401 /]#
[root@ti0203a400-1401 /]# mkdir -p /testdir //創建磁盤掛載目錄
[root@ti0203a400-1401 /]# mount -t ext4 /dev/sda4 /testdir/ //掛載磁盤
[root@ti0203a400-1401 /]# df -h //查看磁盤是否識別并掛載
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 39G 3.3G 34G 9% /
tmpfs 491M 92K 491M 1% /dev/shm
/dev/sda1 190M 55M 126M 31% /boot
/dev/sda4 4.8G 11M 4.6G 1% /testdir
[root@ti0203a400-1401 /]# ls /testdir/
lost+found
[root@ti0203a400-1401 /]#
轉載:
http://miclesvic.blog.51cto.com/2152735/1344202
原創文章,作者:jxmsn,如若轉載,請注明出處:http://www.www58058.com/16100