Linux extend fat32 partition

Расширение диска или раздела Linux

В инструкции рассмотрены сценарии расширения дискового пространства разделов в Linux без потери информации.

Принцип увеличения диска:

  1. Расширение раздела.
  2. Изменение размера файловой системы.

В зависимости от типа раздела и файловой системы, действия различаются.

Любая работа с диском несет риск потери информации. Перед началом работ убедитесь в наличие резервных копий ценных данных.

Шаг 1. Расширение раздела

Обычные тома

Допустим, есть диск /dev/sdb и раздел /dev/sdb2, который нужно увеличить.

Сначала необходимо отмонтировать раздел:

В случае работы с корневой директорией, отмонтировать ее не получиться. В таком случае необходимо загрузить компьютер с LiveCD.

Подключаемся утилитой fdisk к /dev/sdb:

Если мы работаем с разделом более чем 2Тб, используем утилиту parted.

Смотрим номера разделов:

Удаляем раздел (не переживайте — все данные сохраняются):

* в моем примере, раздел для удаления на второй позиции.

Создаем новый раздел:

Номер раздела — 2:

На запрос начального и конечного секторов просто нажимаем Enter.

Если раздел был загрузочный, добавляем соответствующий флаг:

Еще раз проверяем, что получилось:

LVM-тома расширяются на лету, даже для корневых разделов. В данном примере, работаем с /dev/sda.

Открываем диск утилитой fdisk:

* напомню, что при работе с диском 2Тб и более, следует использовать утилиту parted.

Создаем еще один раздел:

Номер раздела оставляем тот, который предлагает система (просто нажимаем Enter).

Первый и последний сектора также оставляем по умолчанию для использования всего дискового пространства (еще два раза Enter).

Задаем тип раздела:

Выбираем номер раздела (в моем примере создавался раздел 3):

Командой L можно посмотреть список всех типов, но нас интересует конкретный — LVM (8e):

Проинформируем систему, что в таблице разделов произошли изменения:

Создаем физический том из нового раздела:

Смотрим наши Volume Group и для нужного добавляем созданный том:

vgextend vg_centos /dev/sda3

* в моем примере группа томов LVM называется vg_centos

Смотрим LVM-разделы и расширяем пространства для нужного:

lvextend -l +100%FREE /dev/vg_centos/lv_root

* данная команда расширяем LVM-раздел /dev/vg_centos/lv_root, используя все свободное пространство (100%FREE).

Шаг 2. Изменение размера для файловой системы

После того, как на предыдущем шаге мы расширили раздел, система по-прежнему будет видеть старый по объему диск. Чтобы это исправить, необходимо выполнить команду по изменению размера файловой системы. В зависимости от последней, команды различаются.

Посмотреть файловую систему:

ext2/ext3/ext4:

XFS:

Reiserfs:

* обратите внимание, что в данных примерах используются различные устройства.

Если раздел был отмонтирован, монтируем его, например:

mount /dev/sda2 /mnt

Проверяем, что настройки применились:

Увеличение разделов с Gparted

Если работы выполняются на системе с графическим интерфейсом или есть возможность перезагрузить сервер и загрузиться с LiveCD, можно воспользоваться простым средством — утилитой Gparted, которая позволяем менять размер разделов мышкой.

Читайте также:  Не запускается msi файл windows 10

Запускаем утилиту — выбираем диск, с которым будем работать — кликаем правой кнопкой по разделу, который хотим увеличить и выбираем Resize/Move:

В открывшемся окне с помощью мышки или форм меняем размер раздела:

Нажимаем кнопку Resize/Move.

Проверяем изменения в окне программы и сохраняем настройки кнопкой «Apply All Operations»:

Источник

Arch Linux

You are not logged in.

#1 2011-12-10 21:15:02

Resize a fat32 partition using linux 3.0

So I have an external hdd that I use as a backup/archive, and it is formatted using fat32. It is 315GB listed, and 293gb actual. It has about 183gb of data on it, and 110 free. I want to keep some of the data, but also switch the whole thing to ext4. My plan was to shrink the partition, use the free space to copy over the stuff I want, reformat the rest over to ext4, then merge the partitions.

Apparently as of parted 0.9.0 you can no longer resize fat32 partitions. Is there another utility that I can use to make this happen? Specifically, one that will work with the linux 3.0 kernel? I don’t have another drive big enough to get everything onto it, so I need to find a way to keep everything on the drive as I flipflop everything around.

#2 2011-12-10 21:18:20

Re: Resize a fat32 partition using linux 3.0

Partition operations are dangerous and you’re advised to back up your stuff. If you don’t can’t do a proper backup, I would think twice before proceeding.

#3 2011-12-10 21:58:01

Re: Resize a fat32 partition using linux 3.0

The kernel version is irrelevant for resizing operations. Tools matter, but you’re correct, the only Linux tool that was capable of resizing fat32, isn’t capable of it anymore. So copy the data to some other disk, and partition this disk from scratch.

Or compile yourself an older version of parted, I’d say they still work.

#4 2011-12-10 22:50:54

Re: Resize a fat32 partition using linux 3.0

How about the Gparted live CD? I have used it often and while it may be slow, it works wonderfully.

Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

#5 2011-12-10 22:52:31

Re: Resize a fat32 partition using linux 3.0

Is there another utility that I can use to make this happen? Specifically, one that will work with the linux 3.0 kernel?

Yes, I just took a look at the latest gparted on the PartedMagic LiveCD and it still offers the option to resize FAT32 partitions. I didn’t test it, but the option is certainly there.

edit: oops, looks like I was typing out a response when B pressed ENTER!

Last edited by ozar (2011-12-10 22:54:05)

#6 2011-12-10 22:55:05

Re: Resize a fat32 partition using linux 3.0

Do you have any free space else where?

1) Copy entire drive to temp space
2) Repartition and format to ext4
3) Copy back

#7 2011-12-11 00:07:06

Re: Resize a fat32 partition using linux 3.0

Yes, I just took a look at the latest gparted on the PartedMagic LiveCD and it still offers the option to resize FAT32 partitions.

Quite possibly PartedMagic links gparted against an old libparted.

edit: oops, looks like I was typing out a response when B pressed ENTER!

Heh, PartedMagic != GParted LiveCD

#8 2011-12-11 18:48:46

Re: Resize a fat32 partition using linux 3.0

Thanks for the responses, guys. Yeah, I am it a bit of a bind, and really should have done something about this sooner, because now I’m stuck. I’m starting to be unable to back up some files without renaming them to strip out special characters, etc, but it’s becoming a problem during large batch backups. Unfortunately, I don’t have another drive with enough space. When my laptop’s hdd went I put in an 80gb x25m ssd, and it’s nearly full. Sounds like a gparted cd could be the way to go.

Читайте также:  Сколько бит установить windows

Any bets on what the chances of me clobbering this would be?

Источник

Arch Linux

You are not logged in.

#1 2012-03-06 16:39:27

[solved]resize Fat32 partition (extend)

I am trying to extend out my external harddrive so its 1 partition , there is currently

200GB unallocated, adjacent and to the right of the primary fat32 partition (which i thought was the criteria for extending/growing) but gparted cant resize, and windows disk management cant extend (greyed out).

what am i doing wrong here.

Last edited by jewnersey (2012-03-06 19:21:41)

#2 2012-03-06 16:56:33

Re: [solved]resize Fat32 partition (extend)

Why isn’t gparted working? Have you tried the liveCD?

#3 2012-03-06 17:01:54

Re: [solved]resize Fat32 partition (extend)

What exactly is happening when you try?

Does it not let you even try expanding the partition or does it fail when you try to commit the changes?
Is the Fat32 partition mounted when you’re trying to modify it?

EDIT: For clarity, I’m asking about what is happening when you try with Gparted.

Last edited by Avant-texte (2012-03-06 17:04:27)

#4 2012-03-06 17:02:31

Re: [solved]resize Fat32 partition (extend)

havnt tried live. just using gparted within my environment as root.

Ill give the liveCD a shot

when i choose «resize» and then try to extend the partition, it doesnt allow it. i can move the paritition as a whole, but cannot increase (or decrease) the size

Last edited by jewnersey (2012-03-06 17:05:31)

#5 2012-03-06 17:06:45

Re: [solved]resize Fat32 partition (extend)

That is odd. If you can move it, you should be able to resize it.

Try the live cd if you can, so we can rule out other environmental issues.

#6 2012-03-06 17:20:57

Re: [solved]resize Fat32 partition (extend)

The only code Linux had for resizing fat32 was in parted-2. It was removed in parted-3, leaving Linux without the ability to resize fat32.

But, now there’s parted-3.1 which has a new library, libparted-fs-resize, adding back fat32 resizing ability. However it seems gparted will need to be updated to use this new library. Using parted on the commanline should work though.

#7 2012-03-06 17:22:56

Re: [solved]resize Fat32 partition (extend)

The only code Linux had for resizing fat32 was in parted-2. It was removed in parted-3, leaving Linux without the ability to resize fat32.

Shit, they pulled that out in 3 too?

#8 2012-03-06 17:25:07

Re: [solved]resize Fat32 partition (extend)

http://gparted.sourceforge.net/features.php#libparted led me to believe all three operations (grow, shrink, move) would be affected.
OP says he can move it .

The only code Linux had for resizing fat32 was in parted-2. It was removed in parted-3, leaving Linux without the ability to resize fat32.

Shit, they pulled that out in 3 too?

They wrote: «Native available through libparted (versions Offline

Источник

Increase the Size of a Linux Root Partition Without Rebooting

Table of Contents

Introduction

A typical Linux server deployed from a ProfitBricks supplied image has a single storage volume, /dev/vda . If we take a look at that using fdisk we will see that the disk is divided into two partitions. The first one, /dev/vda1 , is the boot partition where the OS resides. The second partition, /dev/vda2 , is configured as swap space.

In the example above, the total 50 GB storage volume is split into 46 GB usable space and 4 GB for swap. What if after provisioning we find that 46 GB of disk space is not enough but we prefer not to add an additional storage volume? The goal is to increase the amount of disk space available on the root filesystem. This can be accomplished with minimal disruption. We do not need to reboot the server!

Читайте также:  Windows defender might be impacting your build performance intellij idea

Requirements

  • A Linux Server created from a ProfitBricks supplied image.
  • SSH or console access (via the DCD) to the Linux Server.
  • The partprobe command. Can be installed from the parted package on most Linux distributions.
  • The fdisk , swapoff , mkswap , swapon , and resize2fs commands. Likely available by default.
  • A current snapshot or other backup of the system you are working on. Just to be safe!

Provision Additional Space

To increase the size of the hard drive, go into the DCD (Data Center Designer) and upscale the drive.

After you have increased the amount of drive space, click on «provisioning» to process the change. Takes around a minute and your hard drive is bigger.

We then need to switch off the swap — so make sure you can live a few minutes without swap space:

Once swap has been disabled, we need to reconfigure the partitions using fdisk :

We will delete the two existing partitions first. We run fdisk /dev/vda and then use the d command to delete partition 2, and then delete partition 1. Follow the example below:

Now we recreate our partitions. In the example we have 4 GB of swap space. So we need to keep at least that much space available for the new swap partition.

Recreate /dev/vda1 first. Press n to create a new partition. Enter p to create a primary partition. We can press Enter to accept the default value of 2048 for the first sector. Then enter a size for the partition. You can enter a value in GB, so if we are increasing the disk to 100 GB, we subtract our 4 GB for swap, and enter +96G for 96 GB.

Now we recreate the swap partition following a simalar process. Press n and then p to create a new primary partition. Press Enter to accept the default value for «First sector». We can also press Enter again to accept the default value for «Last sector».

Since this second partition is going to be used for swap space, we need to change the partition type. This can be done by pressing t at the fdisk prompt. We then press 2 to select the second partition. If you want to see the list of available partition types, press L, otherwise enter 82 to select «Linux swap / Solaris».

fdisk helpfully informs us that we have changed the partition type with the message:

After that, we save using the w command and are returned to a shell prompt:

You may get a message like this before the shell prompt:

Lets forgo rebooting and instead tell the kernel about the new partitions using partprobe :

We should be returned to the shell prompt with no output from partprobe .

Now we need to resize our filesystem on /dev/vda1 :

The filesystem on /dev/vda1 is now 25165824 (4k) blocks long.

Initialize the new swap location of /dev/vda2 :

Finally we edit /etc/fstab and replace the old UUID with the new one returned in the output of the mkswap command. The line to change has no value for «mount point» and has «type» set to swap.

After editing /etc/fstab , we need to enable swap again:

Verify

We can verify the new larger disk size by utilizing df and/or fdisk .

We can also confirm that the server was not rebooted by looking at the output of uptime :

Summary

We have successfully increased the amount of disk space available on our Linux server. If you have any questions or comments, please leave them here, or in the DevOps Community section of this site.

Источник

Оцените статью