function formatSize($size) {
$sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
if ($size == 0) {
return('n/a');
} else {
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]);
}
}
$thefile = filesize('test_file.mp3');
echo formatSize($thefile);
]]>由于fdisk
命令最多只支持2TB磁盘分区,并不支持更大的磁盘,需要使用GPT格式进行分区。
[root@localhost ~]# fdisk /dev/sdb -l
Disk /dev/sdb: 10561.8 GB, 10561795743744 bytes, 20628507312 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 262144 bytes / 2883584 bytes
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 447.1G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 446.6G 0 part
├─centos-root 253:0 0 202.6G 0 lvm /
├─centos-swap 253:1 0 64G 0 lvm [SWAP]
├─centos-home 253:2 0 100G 0 lvm /home
└─centos-var 253:3 0 80G 0 lvm /var
sdb 8:16 0 9.6T 0 disk
sr0 11:0 1 1024M 0 rom
开始操作
[root@localhost ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: /dev/sdb: unrecognised disk label
Model: ZTE LOGICAL VOLUME (scsi)
Disk /dev/sdb: 10.6TB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags:
(parted) mklabel gpt
(parted) p
Model: ZTE LOGICAL VOLUME (scsi)
Disk /dev/sdb: 10.6TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) mkpart opt 2048s 100%
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
(parted) p
Model: ZTE LOGICAL VOLUME (scsi)
Disk /dev/sdb: 10.6TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 10.6TB 10.6TB opt
(parted) q
Information: You may need to update /etc/fstab.
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 447.1G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 446.6G 0 part
├─centos-root 253:0 0 202.6G 0 lvm /
├─centos-swap 253:1 0 64G 0 lvm [SWAP]
├─centos-home 253:2 0 100G 0 lvm /home
└─centos-var 253:3 0 80G 0 lvm /var
sdb 8:16 0 9.6T 0 disk
└─sdb1 8:17 0 9.6T 0 part
sr0 11:0 1 1024M 0 rom
[root@localhost ~]# mkfs.ext4 /dev/sdb1
[scode type="share"]来源于:闲云博客[/scode]
]]>