Partition

Centos 5 上的 4 TB 外部磁碟

  • August 25, 2016

我有一台執行 CentOS 5(核心 2.6.18-92.el5)的舊伺服器。它正在執行一個遺留應用程序,所以我還不能退役它。我已將 2 TB USB 磁碟連接到它以進行備份,並且該磁碟現在幾乎已滿。

我買了一個新的 4 TB 磁碟,但作業系統只檢測到它為 2 TB。我知道 fdisk 不支持 2TB 以上的分區,但我也沒有使用 parted 的運氣。

有什麼解決方法可以讓作業系統讀取 4 TB 的全部空間?

來自 dmesg:

usb-storage: device found at 15
usb-storage: waiting for device to settle before scanning
 Vendor: Seagate   Model: Backup+  Desk     Rev: 040B
 Type:   Direct-Access                      ANSI SCSI revision: 06
sdc: Spinning up disk....ready
sdc : very big device. try to use READ CAPACITY(16).
sdc : READ CAPACITY(16) failed.
sdc : status=0, message=00, host=5, driver=00 
sdc : use 0xffffffff as device size
SCSI device sdc: 4294967296 512-byte hdwr sectors (2199023 MB)

分開 /dev/sdc 列印

Model: Seagate Backup+ Desk (scsi)
Disk /dev/sdc: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
1      17.4kB  2100GB  2100GB               primary       

Information: Don't forget to update /etc/fstab, if necessary.

看起來我至少需要 2.6.32 核心來支持更大的磁碟。我的伺服器目前有 2.6.18-92.el5:https ://unix.stackexchange.com/questions/150699/harddisk-not-recognized-filesystem-too-large-to-mount-safely-on-this-system

具有舊版 BIOS 和 MBR 分區表方案的較舊 Linux 核心版本(所有 2.4 和 pre-2.6.32)計算環境在 2.19 TB 時遇到障礙,因為它們最多只能處理 232 個邏輯塊。請務必使用包含對大於 2.19TB 驅動器的支持的核心。2010 年 4 月之後發布的核心支持使用 4096 扇區大小的大容量驅動器。

確保使用ext3文件系統或支持 2TB 以上的文件系統。

使用以下命令創建大於 2TB 的分區 (GPT) 的說明parted

https://sakafi.wordpress.com/2008/08/23/how-to-use-parted-for-creating-patition-larger-that-2-tb/

網站的副本以防它消失:

To create partitions larger than 2TB we need to use GPT labels. Standard fdisk doesn’t understand GPT labels so we need to use parted.

Here we are going to partition the disk /dev/sdb

root@localhost ~> parted /dev/sdb

This will bring up parted.  Type help to view the commands in parted prompt.

(parted) help
check NUMBER                             do a simple check on the file system
cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition
help [COMMAND]                           prints general help, or help on COMMAND
mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on partititon NUMBER
mkpart PART-TYPE [FS-TYPE] START END     make a partition
mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system
move NUMBER START END                    move partition NUMBER
name NUMBER NAME                         name partition NUMBER as NAME
print [free|NUMBER|all]                  display the partition table, a partition, or all devices
quit                                     exit program
rescue START END                         rescue a lost partition near START and END
resize NUMBER START END                  resize partition NUMBER and its file system
rm NUMBER                                delete partition NUMBER
select DEVICE                            choose the device to edit
set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
unit UNIT                                set the default unit to UNIT
version                                  displays the current version of GNU Parted and copyright information

root@localhost ~> parted /dev/sdb
GNU Parted 1.8.1
Using /dev/sdb
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted)

To change the label to gpt we run the following command:

(parted) mklabel gpt

Next run the print command: This will list the disk geometry. Please note the size listed:

(parted) print

Model: Adaptec raid5-1 (scsi)
Disk /dev/sdb: 10.7TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
This will tell us where to start and end the partitions. To create one huge partition ( 8 Tb = 8388608 bytes) run the following commands:

(parted) mkpart primary 0 8388607.000

The command reads as make a primary partition, start at 0 and end at 8388607.000

Also, if you are making a partition for a device smaller than the limit from the notes below, you can use the following if the geometry doesn’t show like it does above. Just exit out of parted, and run this from a shell:

root@localhost ~> parted -s — /dev/sdb  mkpart primary ext3 0 -1

This will take the whole disk for creating the partition.

The parition has been created and now you can quit parted:
(parted) quit

Now all that has to be done is to format the partition:(the -m swith tells mkfs to only reserve 1% of the blocks for the super block)

root@localhost ~> mkfs.ext3 -m1 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1024000000 inodes, 2047999751 blocks
20479997 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
62500 block groups
32768 blocks per group, 32768 fragments per group
16384 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, 1934917632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Mount the disk

root@localhost ~> mount /dev/sdb1 /disk1

root@localhost ~> df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             240G  2.3G  225G   2% /
/dev/sda1             996M   45M  900M   5% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
/dev/sdb1             7.6T  177M  7.5T   1% /disk1

引用自:https://serverfault.com/questions/798677