- Introduction
- Determine Drive Information
- Partition The Disk
- Partitioning Using GParted
- Command Line Partitioning
- GPT vs MBR
- parted
- fdisk
- Command Line Formatting
- Modify Reserved Space (Optional)
- Create A Mount Point
- Mount The Drive
- Automatic Mount At Boot
- Manually Mount
- Need Additional Help?
- Linux — создать GPT раздел более 2 терабайт
- Преимущества GPT
- С помощью parted
- С помощью gdisk
- С помощью fdisk
Introduction
This guide goes over procedures for a single partition drive install only. Multiple partition drive installations are not very hard, and you may very well figure it out by using this guide; however, make sure you add an entry in /etc/fstab for each partition, not just the drive.
A Note about File Systems:
Drives that are going to be used only under Ubuntu should be formatted using the ext3/ext4 file system (depending on which version of Ubuntu you use and whether you need Linux backwards compatibility). For sharing between Ubuntu and Windows, FAT32 is often the recommended file system, although NTFS works quite well too. If you are new to file systems and partitioning, please do some preliminary research on the two before you attempt this procedure.
Determine Drive Information
We assume that the hard drive is physically installed and detected by the BIOS.
To determine the path that your system has assigned to the new hard drive, open a terminal and run:
This should produce output similar to this sample:
*-disk description: ATA Disk product: IC25N040ATCS04-0 vendor: Hitachi physical id: 0 bus info: ide@0.0 logical name: /dev/sdb version: CA4OA71A serial: CSH405DCLSHK6B size: 37GB capacity: 37GB
Be sure to note the «logical name» entry, as it will be used several times throughout this guide.
Partition The Disk
If you have already formatted the drive and it contains data, skip this step and move on to «Mount Point.» If the drive is still blank and unformatted, then you have two options: formatting the drive using the command line, or installing GParted for a graphical approach. Decide whether you want the drive to contain one single partition, or if you want to divide the space up between two or more partitions.
Partitioning Using GParted
If System > Administration > GNOME Partition Editor (or ‘Partition Editor’) is not available, install «GParted» using «sudo apt-get install gparted» from the command line, «Add/Remove Software» (or «Add/Remove. «) from the Applications menu, or «Synaptic Package Manager» from the System > Administration menu. Open GParted and let’s get started.
Always use gksu or gksudo for graphical applications like gparted and sudo for command line applications, like apt-get.
In the top-right corner of the window, choose your new hard drive from the drop-down list, referring back to the «logical name» from earlier. The window should refresh and show you a representation of the new drive. Assuming that the drive has yet to have been used, a white bar will run across the window. Use these steps to partition the drive with a single partition.
1) Right-click on the white bar and choose «New.»
2) For «New Size» the number should be the maximum allowable, to fill the entire disk.
3) Choose «Primary Partition»
4) Now decide on a filesystem. Use «ext3» if the drive will only be used with Ubuntu. For file-sharing between Ubuntu and Windows, you should use «fat32.» If you are unsure, search around the wiki and forums for advice.
5) Now click Add to compute the partition. The graphical display should update to show a new partition covering the entire disk.
6) To finish, click «Apply,» or Edit > Apply. The disk will then be partitioned and formatted. You may now close GParted.
Command Line Partitioning
There are two commands that can be used in the command line to partition a new drive: fdisk and parted. fdisk is an older program, and its main downside is that it can only create MBR partitions. parted allows you to create MBR or GPT partitions.
GPT vs MBR
MBR (Master Boot Record) has two main limitations: you cannot have a partition larger than 2 TB and you cannot have more than 4 primary partitions. GPT (GUID Partition Table) can do both of these things, but it is part of the EFI standard. This means your kernel must support EFI. The latest version of the kernel supports EFI, and almost all the latest distros do too.
parted
Refer back to the logical name you noted from earlier. For illustration, I’ll use /dev/sdb, and assume that you want a single partition on the disk, occupying all the free space.
1) Start parted as follows:
2) Create a new GPT disklabel (aka partition table):
3) Set the default unit to TB:
4) Create one partition occupying all the space on the drive. For a 4TB drive:
(parted) mkpart Partition name? []? primary File system type? [ext2]? ext4 Start? 0 End? 4
Alternatively, you can set the partition size as a percentage of the disk. To create a partition occupying all the space on the drive:
(parted) mkpart Partition name? []? primary File system type? [ext2]? ext4 Start? 0% End? 100%
5) Check that the results are correct:
There should be one partition occupying the entire drive.
fdisk
Refer back to the logical name you noted from earlier. For illustration, I’ll use /dev/sdb, and assume that you want a single partition on the disk, occupying all the free space.
- software that runs at boot time (e.g., old versions of LILO)
- booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Otherwise, this will not negatively affect you.
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):
3) We want to add a new partition. Type «n» and press enter.
Command action e extended p primary partition (1-4)
4) We want a primary partition. Enter «p» and enter.
5) Since this will be the only partition on the drive, number 1. Enter «1» and enter.
If it asks about the first cylinder, just type «1» and enter. (We are making 1 partition to use the whole disk, so it should start at the beginning.)
6) Now that the partition is entered, choose option «w» to write the partition table to the disk. Type «w» and enter.
The partition table has been altered!
7) If all went well, you now have a properly partitioned hard drive that’s ready to be formatted. Since this is the first partition, Linux will recognize it as /dev/sdb1, while the disk that the partition is on is still /dev/sdb.
Command Line Formatting
sudo mkfs -t fat32 /dev/sdb1
As always, substitute «/dev/sdb1» with your own partition’s path.
Modify Reserved Space (Optional)
When formatting the drive as ext2/ext3, 5% of the drive’s total space is reserved for the super-user (root) so that the operating system can still write to the disk even if it is full. However, for disks that only contain data, this is not necessary.
NOTE: You may run this command on a fat32 file system, but it will do nothing; therefore, I highly recommend not running it.
You can adjust the percentage of reserved space with the «tune2fs» command, like this:
This example reserves 1% of space — change this number if you wish.
- Using this command does not change any existing data on the drive. You can use it on a drive which already contains data.
Create A Mount Point
sudo mkdir /media/mynewdrive
Now we are ready to mount the drive to the mount point.
Mount The Drive
You can choose to have the drive mounted automatically each time you boot the computer, or manually only when you need to use it.
Automatic Mount At Boot
Note: Ubuntu now recommends to use UUID instead, see the instructions here:https://help.ubuntu.com/community/UsingUUID
/dev/sdb1 /media/mynewdrive ext3 defaults 0 2
/dev/sdb1 /media/mynewdrive vfat defaults 0 2
The defaults part may allow you to read, but not write. To write other partition and FAT specific options must be used. If gnome nautilus is being used, use the right-click, mount method, from computer folder. Then launch the mount command from terminal, no options. The last entry should be the FAT drive and and look something like:
/dev/sda5 on /media/mynewdrive type vfat (rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush)
You can now run «sudo mount -a» (or reboot the computer) to have the changes take effect.
sudo chown -R USERNAME:USERNAME /media/mynewdrive
sudo chgrp plugdev /media/mynewdrive sudo chmod g+w /media/mynewdrive sudo chmod +t /media/mynewdrive
The last «chmod +t» adds the sticky bit, so that people can only delete their own files and sub-directories in a directory, even if they have write permissions to it (see man chmod).
Manually Mount
Alternatively, you may want to manually mount the drive every time you need it.
For manual mounting, use the following command:
sudo mount /dev/sdb1 /media/mynewdrive
When you are finished with the drive, you can unmount it using:
sudo umount /media/mynewdrive
That’s it
Need Additional Help?
- If you run into problems or need more help, search the wiki or forums at http://ubuntuforums.org. If you cannot find what you are looking for, simply ask for help.
InstallingANewHardDrive (последним исправлял пользователь caconym 2023-06-12 18:45:04)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details
Linux — создать GPT раздел более 2 терабайт
Размеры дисков растут и старый добрый MBR не позволяет создавать разделы больше 2 ТБ. Создаём GPT раздел.
GPT — GUID Partition Table (Таблица разделов GUID). Формат размещения таблиц разделов на физическом диске.
Преимущества GPT
- GPT допускает неограниченное количество основных разделов, в то время как MBR допускает только четыре основных, а остальные — дополнительные.
- GPT позволяет создавать разделы любого размера, в то время как MBR имеет ограничение в 2 ТБ.
- GPT хранит копию данных раздела, позволяя восстановить их в случае повреждения основного заголовка GPT; MBR хранит только одну копию данных раздела в первом секторе жёсткого диска, что может привести к потере всей информации в случае повреждении информации о разделах.
- GPT хранит значения контрольной суммы для проверки, что данные не повреждены, и может выполнить необходимое восстановление из других областей диска в случае повреждения; MBR не имеет способа узнать о повреждении данных, вы можете узнать об этом только если компьютер откажется загружаться или исчезнет раздел.
С помощью parted
parted /dev/sdb --script mklabel gpt parted /dev/sdb --script mkpart primary ext4 0 0
С помощью gdisk
# gdisk /dev/sdb GPT fdisk (gdisk) version 1.0.3 Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present *************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format! *************************************************************** Command (? for help): n Partition number (1-128, default 1): First sector (34-4194270, default = 2048) or size: Last sector (2048-4194270, default = 4194270) or size: Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem' Command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): Y OK; writing new GUID partition table (GPT) to /dev/sdb. The operation has completed successfully.
С помощью fdisk
fdisk начиная с linux-utils 2.30.2 теперь понимает GPT.
fdisk /dev/sdb Welcome to fdisk (util-linux 2.31.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. The size of this disk is 229.2 TiB (251991636836352 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT). Command (m for help): g Created a new GPT disklabel (GUID: ECC64CB5-EA6C-0044-B63C-32C595B66F76). The old dos signature will be removed by a write command. Command (m for help): n Partition number (1-128, default 1): First sector (2048-492171165662, default 2048): Last sector, +sectors or +size (2048-492171165662, default 492171165662): Created a new partition 1 of type 'Linux filesystem' and of size 229.2 TiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.