LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-07-2024, 04:36 PM   #16
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,760

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931

While it isn't a definitive answer from my test the file offset remained the same with the original partition 2 as when it was resized to the entire drive which implies the file was moved.

Expanding a partition should not lead to data loss and many filesystems allow you to expand "on the fly" i.e. while it is mounted. resizing smaller or moving is always best when the filesystem is unmounted. In the case of your example the steps would be to move first then expand. Regardless of what operation is being performed you should always have a backup of data you do not want to lose because you never no what might happen.

Last edited by michaelk; 01-07-2024 at 04:43 PM.
 
Old 01-07-2024, 06:14 PM   #17
maybeJosiah
Member
 
Registered: Jan 2024
Location: USA
Distribution: Ubuntu, Android, Ubuntu Touch, Jolla Sailfish maybe
Posts: 195
Blog Entries: 2

Rep: Reputation: 5
I think it will stay put and not be moved on bigger partition but I am no expert maybe or maybe not, maybe.
 
Old 01-08-2024, 06:53 AM   #18
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,811

Rep: Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210Reputation: 1210
If you delete the 1st partition, the data on the 2nd partition is untouched.
Then you certainly have the problem that the sectors of the 1st partition are before the 2nd partition, and a file system can grow at its end only. And a simple partition manager like (g)parted cannot move or remap any data.
The solution that I know:
move the 2nd partition to a volume manager (usually LVM). Under the volume manager the data is still there, but in a new device path, a virtual disk. The virtual device can always grow; if you grow it by the 1st partition then the LVM will remap the low sectors to high sectors. And the file system can grow normally (online).
 
Old 01-08-2024, 07:01 AM   #19
EMilstone
LQ Newbie
 
Registered: Aug 2003
Distribution: Fedora, Mint, Ubuntu, Debian, Manjaro
Posts: 22

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by MadeInGermany View Post
If you delete the 1st partition, the data on the 2nd partition is untouched.
Then you certainly have the problem that the sectors of the 1st partition are before the 2nd partition, and a file system can grow at its end only. And a simple partition manager like (g)parted cannot move or remap any data.
The solution that I know:
move the 2nd partition to a volume manager (usually LVM). Under the volume manager the data is still there, but in a new device path, a virtual disk. The virtual device can always grow; if you grow it by the 1st partition then the LVM will remap the low sectors to high sectors. And the file system can grow normally (online).
Thank you for this. Makes sense - as far as my somewhat limited understanding of LVMs goes.
 
Old 01-08-2024, 11:26 AM   #20
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,547

Rep: Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498Reputation: 2498
You can get detailed information on GParted if that is what you are going to use by reading through their online manual at the link below. Go to the Advanced Partition Actions section of the Table of Contents. According to this, if you delete a partition, you can expand the partition either way and also copy data but it will take quite a while to do with a partition of 1TB. As stated at the site, it would be problematic (possibly) if it was a boot drive with boot files on it, the 2nd partition you want to move.

https://gparted.org/display-doc.php%...%3Dhelp-manual

Last edited by yancek; 01-09-2024 at 05:01 AM.
 
Old 01-08-2024, 05:31 PM   #21
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by lvm_ View Post
Operations on partition table affect nothing but the partition table, the data will stay where it was. If you do this however, results could surprise you: filesystems typically expect to find superblock or equivalent data structure at the start of the block device (partition), so if you try to mount this monstrosity you'll find the contents of partition 1, and contents of partition 2 will become inaccessible.
This may or may not be true depending upon which tool is used.
Gparted manages moving, resizing, formatting, etc. on partitions and will cleanly delete partition 1 then resize partition 2 to occupy that space without any of the mentioned errors. It even recreates the appropriate superblocks and backups for the newer enlarged partition size so the user is not caught by surprise.

Thus, with the proper tools this type task is easy. In the past when doing everything manually with only a partition management tool your scenario may have been valid, but not today when using the proper tools.

My suggestion, since the OP claimed to have an up-to-date copy of the data made with rsync would have been to simply enlarge the partition, reformat, then restore from his backup.

With the concern about times for the files, a tar archive of the data would save and restore the existing times for each file.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Resize boot partition, transfer free space from other partition Superblond Linux - General 12 12-02-2021 10:36 AM
[SOLVED] What happens to gpt partition numbering when you delete a partition? hazel Linux - General 4 05-07-2019 06:42 AM
delete third partition (what happens?) invasian Linux - General 1 09-24-2004 04:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration