官术网_书友最值得收藏!

  • Ubuntu 20.04 Essentials
  • Neil Smyth
  • 910字
  • 2021-06-11 17:39:34

6.2 Deleting the Windows Partitions from the Disk

The first step in freeing up the Windows partition for use by Ubuntu is to delete that partition. Before doing so, however, it is imperative that any data you need to keep is backed up from both the Windows and Ubuntu partitions. Having done that, it is safe to proceed with this chapter.

In order to remove the Windows partitions we first need to identify the disk on which they reside using the fdisk tool:

# fdisk -l

Disk /dev/loop0: 3.7 MiB, 3862528 bytes, 7544 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

.

.

Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 1187839 1185792 579M 7 HPFS/NTFS/exFAT

/dev/sda2 1187840 59770533 58582694 28G 7 HPFS/NTFS/exFAT

/dev/sda3 59770878 104855551 45084674 21.5G 5 Extended

/dev/sda5 59770880 104855551 45084672 21.5G 83 Linux

.

.

In the above example output the system contains one physical disk drive referenced by device name /dev/sda. On that disk drive are five partitions accessed via the device names /dev/sda1 through /dev/sda5 respectively. Based on the values in the System column, there are two NTFS partitions. The first is the Windows system partition while the second, much larger, NTFS partition is the Windows boot partition containing the Windows operating system and user data. On some systems, an additional Windows Recovery partition may be listed and may also be deleted to free up space for Ubuntu. If such a partition exists, it will likely be listed as follows::

/dev/sda3 967012352 976771071 9758720 4.7G 27 Hidden NTFS WinRE

To remove the partitions, start the fdisk tool using the device name of the disk containing the partition (/dev/sda in this instance) and follow the instructions to once again display the partition and sector information:

# fdisk /dev/sda

 

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.

 

Command (m for help): p

Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Disk identifier: 0x7ef44412

 

Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 1187839 1185792 579M 7 HPFS/NTFS/exFAT

/dev/sda2 1187840 59770533 58582694 28G 7 HPFS/NTFS/exFAT

/dev/sda3 59770878 104855551 45084674 21.5G 5 Extended

/dev/sda5 59770880 104855551 45084672 21.5G 83 Linux

 

Command (m for help):

Currently, the Windows system partition is listed as being the bootable partition. Since we will be deleting this partition, the Linux boot partition needs to be marked as bootable. In the above configuration, this is represented by /dev/sda3. Remaining within the fdisk tool, make this the bootable partition as follows:

Command (m for help): a

Partition number (1,3-5, default 5): 3

The bootable flag on partition 3 is enabled now.

Before proceeding, make a note of the start and end addresses of the partitions we will be deleting (in other words the start of /dev/sda1 and the sector before the start of /dev/sda3).

At the command prompt, delete the Windows partitions (these being partitions 1 and 2 on our example system):

Command (m for help): d

Partition number (1-5, default 5): 1

 

Partition 1 has been deleted.

 

Command (m for help): d

Partition number (2-5, default 5): 2

 

Partition 2 has been deleted.

Now that we have deleted the Windows partitions we need to create the new partition in the vacated disk space. The partition number must match the number of the partition removed (in this case 1) and is going to be a primary partition. It will also be necessary to enter the Start and End sectors of the partition exactly as reported for the old partition (fdisk will typically offer the correct values by default, though it is wise to double check). If you are prompted to remove the NTFS signature, enter Y:

Command (m for help): n

Partition type

   p primary (0 primary, 1 extended, 3 free)

   l logical (numbered from 5)

Select (default p): p

Partition number (1,2,4, default 1): 1

First sector (2048-104857599, default 2048):

Last sector, +sectors or +size{K,M,G,T,P} (2048-59770877, default 59770877):

 

Created a new partition 1 of type 'Linux' and of size 28.5 GiB.

Partition #1 contains a ntfs signature.

 

Do you want to remove the signature? [Y]es/[N]o: Y

 

The signature will be removed by a write command.

Having made these changes the next step is to check that the settings are correct (taking this opportunity to double check that the Linux boot partition is bootable):

Command (m for help): p

Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Disk identifier: 0x7ef44412

 

Device Boot Start End Sectors Size Id Type

/dev/sda1 2048 59770877 59768830 28.5G 83 Linux

/dev/sda3 * 59770878 104855551 45084674 21.5G 5 Extended

/dev/sda5 59770880 104855551 45084672 21.5G 83 Linux

 

Filesystem/RAID signature on partition 1 will be wiped.

To commit the changes we now need to write the new partition information to disk and quit from the fdisk tool:

Command (m for help): w

The partition table has been altered.

Syncing disks.

主站蜘蛛池模板: 大港区| 高密市| 清涧县| 黄平县| 宁蒗| 松滋市| 治多县| 衢州市| 宜宾县| 天水市| 锡林郭勒盟| 施甸县| 罗江县| 哈巴河县| 淮安市| 桃江县| 古蔺县| 通城县| 中牟县| 佳木斯市| 太湖县| 新闻| 延长县| 从化市| 崇明县| 临潭县| 老河口市| 香港| 湖州市| 新河县| 柯坪县| 铜梁县| 宁武县| 布拖县| 璧山县| 岢岚县| 深圳市| 渭源县| 曲沃县| 南阳市| 旬阳县|