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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

life1024

你的鼓励将是我创作的最大动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值