2T以上硬盤分區的問題

當在linux中使用fdisk對大於2T的硬盤進行分區的時候,只能使用其中的2T,剩餘的就無法分區掛載,可使用parted命令進行對2T以上硬盤進行分區

1.2T及以下硬盤分區方法

[root@localhost ~]# fdisk /dev/sdm
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x286f1369.
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)
 
WARNING: The size of this disk is 4.0 TB (3999999687168 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID 
partition table format (GPT).
 
 
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
 
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 compatibility flag
   d   delete a partition
   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): n  --增加分區
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1   --設置分區ID
First cylinder (1-486305, default 1):    --直接回車,設置開始柱面,默認爲1
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349):   --直接回車,設置結束柱面,默認爲磁盤的最大空間
Using default value 267349
 
Command (m for help): w   --寫入磁盤並退出
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.

2.大硬盤(2T以上)硬盤分區方法

[root@llocalhost ~]# parted /dev/sdm     --對sdm進行操作
GNU Parted 1.8.1
使用 /dev/sdm
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt               -設置分區類型爲gpt
警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
parted: invalid token: gpt
是/Yes/否/No? yes                                                         
新的磁盤標籤類型?  [gpt]?       回車                                         
(parted) mkpart                                                           
分區名稱?  []?        回車                                                   
文件系統類型?  [ext2]? ext4                                             
起始點? 0                                                 
結束點? 3T            --大小3TB,按實際要求設置,全盤都劃爲一個分區寫-1                                          
(parted) quit

3.格式化分區

[root@localhost ~] mkfs.ext4 -T largefile /dev/sdm1
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdm1 alignment is offset by 3072 bytes.
This may result in very poor performance, (re)-partitioning suggested.
文件系統標籤=
OS type: Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3814784 inodes, 976562183 blocks
48828109 blocks (5.00%) reserved for the super user
第一個數據塊=0
Maximum filesystem blocks=4294967296
29803 block groups
32768 blocks per group, 32768 fragments per group
128 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848, 512000000, 550731776, 644972544
 
Allocating group tables: 完成                            
正在寫入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成


4.掛載分區
 

[root@localhost ~]# mkdir /home/data1                --創建掛載點
[root@localhost ~]# mount /dev/sdm1 /home/data1   --掛載sdm1
[root@localhost ~]# tune2fs -m 1 /dev/sdm1     
tune2fs 1.41.12 (17-May-2010)
Setting reserved blocks percentage to 1% (4883780 blocks)
linux的硬盤分區程序會自動爲root或指定的用戶保留一定的磁盤空間,默認是5%。在較大的分區上這種設置會佔據過多不必要的空間,此命令可以將保留的空間設置爲1%

5.將分區信息寫入/etc/fstab文件

1.獲取硬盤分區UUID

[root@localhost ~]# blkid /dev/sdm1
/dev/sdm1: UUID="86269080-ad85-4811-9a3c-c77ce8282e2d" TYPE="ext4"
2.在/etc/fstab里加入最後一行,保存退出
# /etc/fstab
# Created by anaconda on Sat Dec 12 15:44:41 2015
#
# 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=e3dfd3df-2cf5-449b-8ed7-0a3a9fde8255 /                       ext3    defaults        1 1
UUID=f0378ca7-e884-480a-aaef-4a34623b18e3 /boot                   ext3    defaults        1 2
UUID=5bbf4384-d4c4-4ec6-9950-57ddebf1fed6 /home                   ext3    defaults        1 2
UUID=5b0a63a0-b8c2-4a0b-bad9-a9b351de0b14 swap                    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

還可參看https://wenku.baidu.com/view/2f6198c42cc58bd63186bd0f.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章