Announcement

Collapse
No announcement yet.

How do I partition the disk after installation?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [System] How do I partition the disk after installation?

    I installed Kubuntu 22.04.4 and did not partition the disk during installation. That is, everything is placed on one disk and the system and home directory.
    Tried the pre-installed program, it only shows the total size, no option to split/resize.
    Accordingly, I have a question. How to split the disk into system and home directory in already installed Kubuntu?

    A detailed answer if possible, I am a beginner.​

    #2
    The preferred way to do this is partition before installation or do it during installation using "Manual Partitioning." You can't resize a partition while it's mounted so you have to boot to a Live USB session and then you can shrink the install partition to make space for an additional partition.

    Gparted Live is your best tool to do this but you can do it from your Installation device - USB or CDROM - and use KDE Partition Manager.

    Another option would be to re-install from scratch and partition the disk before running the installer. Then use "Manual Partitioning" during install.

    You could convert the file system to BTRFS (or use BTRFS) when re-installing. Then you do not need to partition at all because BTRFS allows you to use subvolumes to separate home from root.

    Please Read Me

    Comment


      #3
      Thank you for your reply

      What are the mandatory partitions?
      System and Home directory?
      System is "/' and home directory is "Home"
      Or how are they displayed on installation?

      One more thing. How much to allocate for the system?​

      Comment


        #4
        Mandatory partitions for a non-encrypted Linux desktop installation are nowadays:
        1. a) for "legacy" BIOS systems (with a GPT partition table instead of MBR): a 8 MIB unformatted partition with the bios-grub flag, not mounted
          OR
          b) for UEFI systems: a 304 MiB (make sure to use >= 300 MiB so future installations like e.g. with 24.04's Calamares installer will work) FAT32 partition with the esp,boot flag, mounted at /boot/efi
        2. a partition with a Linux file system like e.g. ext4, Btrfs or XFS, mounted at /
        Everything else (like swap, /home, /boot, /var etc. partitions) is optional and depends on your individual use case - so do their sizes…


        PS: Splitting and resizing (non-logical) partitions is better done before installation - it is cumbersome and error-prone to do so after a system has been installed, not matter if Windows, Linux or macOS
        If you absolutely have to do this after a system installation I would also suggest to boot from a GParted live USB for this.

        If you are generally interested in Kubuntu (22.04 LTS) also have a look at Recommended things to do directly after a Kubuntu 22.04 LTS installation
        and
        Overview: Kubuntu, its parent and some of its siblings
        Last edited by Schwarzer Kater; May 23, 2024, 08:21 AM. Reason: added PS, correction for "legacy" BIOS
        Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
        Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

        get rid of Snap script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
        install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

        Comment


          #5
          "Mandatory?" - Only a root partition and if using UEFI, an ESP partition (300mb, fat32, mounted at /boot/efi). No others are mandatory.

          A /home partition is a good idea if you are not using a BTRFS file system.

          A swap partition is a good idea if you're installing more than one distro on the same pc, but the current installers will create a swap file if no swap partition is found.

          For the system partition size (again, if not BTRFS), I would say at least 35-40GB. My very old and loaded-with-software KDENeon install uses 30.6GB of space.

          Please Read Me

          Comment


            #6
            Originally posted by VMelnik View Post
            Thank you for your reply

            What are the mandatory partitions?
            System and Home directory?
            System is "/' and home directory is "Home"
            Or how are they displayed on installation?

            One more thing. How much to allocate for the system?​
            For an EFI system you need a /boot/efi tiny partition bigger than 300MB to stop this new installer complaining it is listed as that in the installer for the Use partition as option when it is selected sometimes labeled as system partition or such. Then the / partition again displayed as that in the Use as option I have it set for 40GB. The "Home" is /home in the Use partition as option and is not a required partition as you have found, those files will be kept in the / without a separate partition setup during install. As you can see below my / only uses 12G. I put the /boot/efi as the first partition on all installs.

            Code:
            zeus@9600k:~$ df -h
            Filesystem Size Used Avail Use% Mounted on
            tmpfs 3.2G 5.0M 3.2G 1% /run
            /dev/nvme1n1p2 40G 12G 28G 30% /
            tmpfs 16G 122M 16G 1% /dev/shm
            tmpfs 5.0M 24K 5.0M 1% /run/lock
            efivarfs 256K 65K 187K 26% /sys/firmware/efi/efivars
            /dev/nvme1n1p3 79G 23G 55G 29% /home
            /dev/nvme1n1p1 200M 6.2M 194M 4% /boot/efi
            
            ​
            My /home not much either but I keep all my large files on other partitions. In the manual step you have the option to choose the file system use I always go with the tried and true ext4, select the format option available to have it formatted as such.

            Comment


              #7
              Originally posted by Schwarzer Kater View Post
              ...for "legacy" BIOS systems: a 8 MIB unformatted partition...
              Just because I like splitting hairs;
              1. AFAIK, a bios-grub flagged partition is only needed IF one is using a GPT partition table - which is a good idea IMO so yes, required and GPT should be used as well.
              2. Just like the "required" 300MB of space for for the "/boot/efi", 8MIB is a totally excessive amount for a bios-boot (bios-grub flagged) partition. Mine are 1007.00 KB and work perfectly. 1007KB happens to be the amount of space available between the partition header and the first aligned partition - sectors 34 to 2047.
              Last edited by oshunluvr; May 23, 2024, 08:13 AM.

              Please Read Me

              Comment


              • Schwarzer Kater
                Schwarzer Kater commented
                Editing a comment
                You are absolutely right, of course! Thanks, I added a correction.

              #8
              Originally posted by oshunluvr View Post
              […]
              For the system partition size (again, if not Btrfs), I would say at least 35-40GB. My very old and loaded-with-software KDENeon install uses 30.6GB of space.
              VMelnik :
              Install a lot of Snaps (*yuck*) or use some virtual machines with QEMU/KVM (whose disk images are installed to /var by default) for example - and you will easily use much more than this…

              Either use e.g. Btrfs as oshunluvr already suggested (and jump through one or two hoops ) or define your use case if you want to have a reasonably useful suggestion…
              Last edited by Schwarzer Kater; May 23, 2024, 08:23 AM. Reason: typo
              Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
              Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

              get rid of Snap script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
              install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

              Comment


              • oshunluvr
                oshunluvr commented
                Editing a comment
                Excellent point. I don't use ANY snaps nor do I use many flatpack or appimages. At least appimages are easily placed in /home.

                I suppose given the above, 60-80GB might be a better starting size.

              #9
              I'm trying to reinstall Kubuntu and at the disk partitioning stage it shows 6 partitions that cannot be merged into one.
              That is, it is impossible to partition from the beginning
              There are 2 partitions, I assume virtual partitions, which are divided into several more and these 2 partitions are not merged into one.
              How can I format the disk so that there is 1 partition, which I can then divide into 2 (system and home directory)?​

              Comment


                #10
                This is what is displayed
                You may only view thumbnails in this gallery. This gallery has 1 photos.

                Comment


                  #11
                  Originally posted by VMelnik View Post
                  I'm trying to reinstall Kubuntu and at the disk partitioning stage it shows 6 partitions that cannot be merged into one.
                  That is, it is impossible to partition from the beginning
                  There are 2 partitions, I assume virtual partitions, which are divided into several more and these 2 partitions are not merged into one.
                  How can I format the disk so that there is 1 partition, which I can then divide into 2 (system and home directory)?​
                  Open a konsole window since you care little about the contents of the disk use the following commands.

                  First sudo gdisk /dev/sd? replace the ? with the drive letter you wish to use if nvme disk then use its /dev/nvme?. Once it opens the disk use the o then ENTER key to create new partition table. Answer yes to doing it then the letter n then ENTER key to create new partition. Take the default selected number by again ENTER key. For first sector again ENTER key for default and last sector type in +300M and again ENTER key to get that size used. When asked the type use the ef00 typed in then ENTER key to create an EFI system partition. You now continue on using the n to create the partitions as you want. Below I show a recent use of it to create a new install disk for a mini computer I bought before cloning my install to it.

                  Code:
                  root@8400t:~# gdisk /dev/sdb
                  GPT fdisk (gdisk) version 1.0.10
                  
                  Partition table scan:
                    MBR: protective
                    BSD: not present
                    APM: not present
                    GPT: present
                  
                  Found valid GPT with protective MBR; using GPT.
                  
                  Command (? for help): d
                  Using 1
                  
                  Command (? for help): n
                  Partition number (1-128, default 1):
                  First sector (34-31251693534, default = 2048) or {+-}size{KMGTP}:
                  Last sector (2048-31251693534, default = 31251691519) or {+-}size{KMGTP}: +200M
                  Current type is 8300 (Linux filesystem)
                  Hex code or GUID (L to show codes, Enter = 8300): ef00
                  Changed type of partition to 'EFI system partition'
                  
                  Command (? for help): n
                  Partition number (2-128, default 2):
                  First sector (34-31251693534, default = 411648) or {+-}size{KMGTP}:
                  Last sector (411648-31251693534, default = 31251691519) or {+-}size{KMGTP}: +40G
                  Current type is 8300 (Linux filesystem)
                  Hex code or GUID (L to show codes, Enter = 8300):
                  Changed type of partition to 'Linux filesystem'
                  
                  Command (? for help): n
                  Partition number (3-128, default 3):
                  First sector (34-31251693534, default = 84297728) or {+-}size{KMGTP}:
                  Last sector (84297728-31251693534, default = 31251691519) or {+-}size{KMGTP}: +80G
                  Current type is 8300 (Linux filesystem)
                  Hex code or GUID (L to show codes, Enter = 8300):
                  Changed type of partition to 'Linux filesystem'
                  
                  Command (? for help): n
                  Partition number (4-128, default 4):
                  First sector (34-31251693534, default = 252069888) or {+-}size{KMGTP}:
                  Last sector (252069888-31251693534, default = 31251691519) or {+-}size{KMGTP}:
                  Current type is 8300 (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.​
                  As you can see from my notes I created four partitions on the drive a 40G for the / and 80G for the /home and the rest to be used for the file storage
                  on that massive external drive the whole purpose of doing the drive this way. The last partition creation shows how to use the rest of the drive for your /home if wanting to do this instead of the storage I used. I simply d the single partition on the drive in this instance and once done you use the w then ENTER key to tell it to write to disk and confirm with a y to do it. The output of the fdisk command after doing it.

                  Code:
                  root@8400t:~# fdisk -l
                  
                  Disk /dev/sdb: 14.55 TiB, 16000867106816 bytes, 31251693568 sectors
                  Disk model: Elements 25A3
                  Units: sectors of 1 * 512 = 512 bytes
                  Sector size (logical/physical): 512 bytes / 4096 bytes
                  I/O size (minimum/optimal): 4096 bytes / 4096 bytes
                  Disklabel type: gpt
                  Disk identifier: 1D0CF95A-68BF-4EA2-9C92-FBA2A42FA244
                  
                  Device Start End Sectors Size Type
                  /dev/sdb1 2048 411647 409600 200M EFI System
                  /dev/sdb2 411648 84297727 83886080 40G Linux filesystem
                  /dev/sdb3 84297728 252069887 167772160 80G Linux filesystem
                  /dev/sdb4 252069888 31251691519 30999621632 14.4T Linux filesystem​
                  Now if wanting to format it.

                  Code:
                  root@8400t:~# mkfs.vfat /dev/sdb1
                  mkfs.fat 4.2 (2021-01-31)
                  root@8400t:~# fatlabel /dev/sdb1 ELEMENTSEFI
                  root@8400t:~# mkfs.ext4 -m 0 -L ElementsRoot /dev/sdb2
                  mke2fs 1.47.0 (5-Feb-2023)
                  Creating filesystem with 10485760 4k blocks and 2621440 inodes
                  Filesystem UUID: 57cd2293-ca19-4333-8cda-49d111cac269
                  Superblock backups stored on blocks:
                  32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
                  4096000, 7962624
                  
                  Allocating group tables: done
                  Writing inode tables: done
                  Creating journal (65536 blocks): done
                  Writing superblocks and filesystem accounting information: done
                  
                  root@8400t:~# mkfs.ext4 -m 0 -L ElementsHome /dev/sdb3
                  mke2fs 1.47.0 (5-Feb-2023)
                  Creating filesystem with 20971520 4k blocks and 5242880 inodes
                  Filesystem UUID: 6097b38a-25f2-4d6c-9043-8fdbf1c62f8e
                  Superblock backups stored on blocks:
                  32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
                  4096000, 7962624, 11239424, 20480000
                  
                  Allocating group tables: done
                  Writing inode tables: done
                  Creating journal (131072 blocks): done
                  Writing superblocks and filesystem accounting information: done
                  
                  root@8400t:~# mkfs.ext4 -m 0 -L ElementsMedia /dev/sdb4
                  mke2fs 1.47.0 (5-Feb-2023)
                  Creating filesystem with 3874952704 4k blocks and 484372480 inodes
                  Filesystem UUID: 6e2245ce-f9b6-4ee5-8e21-d73d77eec311
                  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,
                  2560000000, 3855122432
                  
                  Allocating group tables: done
                  Writing inode tables: done
                  Creating journal (262144 blocks): done
                  Writing superblocks and filesystem accounting information: done
                  The first shows the vfat file system being created for the EFI partition then since I am like that I label it as such. The second through fourth shows the formatting with ext4 using the -m 0 to not waste 5% of the drive with reserve blocks with the again labels for each partition set. What it looks like to blkid once done.

                  Code:
                  root@8400t:~# blkid | grep sdb
                  /dev/sdb1: SEC_TYPE="msdos" LABEL_FATBOOT="ELEMENTSEFI" LABEL="ELEMENTSEFI" UUID="91E6-7A37" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="ecfaee8c-f16b-409e-99c7-a1d15c01aef6"
                  /dev/sdb4: LABEL="ElementsMedia" UUID="6e2245ce-f9b6-4ee5-8e21-d73d77eec311" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="e1e970d4-73d4-4b7c-84af-3d6c2c00b7d9"
                  /dev/sdb2: LABEL="ElementsRoot" UUID="57cd2293-ca19-4333-8cda-49d111cac269" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="ee353292-fd45-4d10-8759-959e326a8777"
                  /dev/sdb3: LABEL="ElementsHome" UUID="6097b38a-25f2-4d6c-9043-8fdbf1c62f8e" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="07be0b70-86b8-4c9f-9b9f-03df327a94b9"​
                  With this disk I can boot on any computer I want having all of my files at hand.

                  Edit: and since I enable root and use it for this you would need sudo in front of all the commands shown.

                  Comment


                    #12
                    I found a way out of the situation.
                    I booted into Ubuntu via USB and already through Ubuntu erased all the partitions.
                    I'm going to install Kubuntu, but I'll probably switch back to Ubuntu.

                    Thank you all for your help.​

                    Comment

                    Working...
                    X