using Gparted
note:see images below
using Gparted as a Live CD to configure drives for setup, or to Rescue a system
At this point let's make sure I'm saying this clearly enough... it is G-parted, not Jeep-parted... that's a different web page..
The GNOME Partition Editor is a Debian based LIVE CD.
GParted is a free partition editor for graphically managing your disk partitions.
With GParted you can resize, copy, and move partitions without data loss, enabling you to:
Grow or shrink your C: drive
Create space for new operating systems
Attempt data rescue from lost partitions
Features:
Perform actions with partitions such as:
create or delete / resize or move / check / label / set new UUID / copy and paste
Manipulate file systems such as:
btrfs / ext2 / ext3 / ext4 / fat16 / fat32 / hfs / hfs+ / linux-swap / lvm2 pv / nilfs2 / ntfs / reiserfs / reiser4 / ufs / xfs
You can download the tool from: http://gparted.org/
THIS TOOL IS DIFFERENT than the command line tool, the GNU command "parted":
DESCRIPTION
parted is a disk partitioning and partition resizing program. It allows you to create, destroy, resize, move and copy ext2,
linux-swap, FAT, FAT32, and reiserfs partitions. It can create, resize, and move Macintosh HFS partitions, as well as detect
jfs, ntfs, ufs, and xfs partitions. It is useful for creating space for new operating systems, reorganising disk usage, and
copying data to new hard disks.
Both parted and fdisk are able to do similar tasks, but fdisk is limited in the size of the disks it can manage, requiring the use of parted.
parted -l can be used to list partition layout on all block devices
example of parted:
--> sudo parted -l
Model: ATA ST2000DM001-1CH1 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 2155MB 2154MB primary linux-swap(v1) type=82
2 2155MB 2000GB 1998GB primary ext4 boot, type=83
Model: ATA ST4000DM000-1F21 (scsi)
Disk /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 4001GB 4001GB ext4 primary
compared to fdisk, note the differences in the output:
--> sudo fdisk -l
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes, 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xf852f852
Device Boot Start End Blocks Id System
/dev/sda1 2048 4208639 2103296 82 Linux swap / Solaris
/dev/sda2 * 4208640 3907028991 1951410176 83 Linux
Disk /dev/sdb: 4000.8 GB, 4000787030016 bytes, 7814037168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 1 4294967295 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.
USING THE CD or USB
For full details on using Gparted live see: http://gparted.org/livecd.php
After downloading the software, boot the system up. In these pictures I used a CD.
This old disk drive was found in the cabinet, a very old version of SuSE Linux that I'd forgotten the password to.
To see a larger version of these images, right mouse click, view image, then use back to get back to this page.
I used Gparted as a live CD to open a terminal, create a mount point and then examine the drive.
To see what's on the drive the following steps were used:
1) Boot to CD, see screen shots below that show the logical steps and default responses, at screen 5 you
can see the graphical representations of the drive.
2) In picture #6 the terminal window is opened.
however the default colors are hard to use, so in step #7 I changed it to black text on a light background.
3) In picture #8 I used "fisk -l", but before I could execute that command, I had to become root user, so
I executed: sudo su - (the sudo is a tool that allows a normal user to gain access to tools reserved
for the root user. "su" is the command to switch user. The "-" is very important as that tells the shell
to source the root user's profile and configuration, otherwise commands might not work properly.
4) As I examine the file system I see two partitions that would have files. /dev/sda2 and /dev/sda3. /dev/sda1 is the swap
partition. /dev/sda2 is the bootable section, so this is likely where the "root" ( / ) filesystem is, this would be the
place with the passwd file and configuration information. /dev/sda3 will likely be the home directory. I determined that I
would mount both the system and the home file systems.
5) In order to mount the drive to the Live CD I needed to create a mount point, then mount the device to that mount point in the
file system. The use of /a is an old practice that I learned from a crusty old Solaris Sys Admin. Although one could create
any name to mount the disk partition to. Once both filesystems are mounted, then I can do a number of things.
6) THE COMMANDS once you've accessed the Terminal window are:
sudo su -
fdisk -l
mkdir /a ; mount /dev/sda2 /a
mkdir /b ; mount /dev/sda3 /b
df -h
ls -al /a/etc/pa* (looking for passwd)
ls -al /b/ (looking for the user accounts)
7) If the mounts are correct, and I'm trying to restore access to this device, or even add a new user, I would do the following:
cd /a/etc/ ; cp passwd passwd-orig-7dec2014 ; cp shadow shadow-orig-7dec2014
vi passwd (I would look for the user accounts I wanted to access, and could add one at this point)
vi shadow (I would remove the encrypted string for the accounts I wanted to access, typically root and my own account)
8) If I were going to add a user I'd need to add that userid and info to passwd, an entry in shadow and in group and make
a user home directory on the /b mount and chown based on that userid, instead of a name. Below would be an example of steps:
cd /a/etc/ ; cat billybob:x:1000:100:billybob:/home/billybob:/bin/bash >> passwd
cat billybob: :16397:0:99999:7::: >> shadow
(I might add the userid for billybob in the group file for various tools, YMMV depending on the distro)
cd /b/ ; mkdir billybob ; cp /.bashrc billybob/ ; mkdir billybob/bin billybob/.History ; chown -R billybob billybob
umount /a ; umount /b ; eject ; reboot (or init 6)
9) After you've unmounted the disks and reboot the system with the last line, and have removed the CD, let the system come up.
10) Log in as root if you can, or as your userid. Neither will have a passwd, it is imperative to set one IMMEDIATELY.
(as root) passwd root (set new passwd)
(as root) passwd user (set passwd)
(as root) passwd billybob (set passwd)
(as root) su - billybob (verify account, copy any other configuration files and make sure he owns his account, change the passwd)
(as billybob) exit (you should now be root again)
(as root) su - (your userid) (verify that you are in your home account, examine files and that you have permissions)
(as you) su - root (enter root's passwd, verify that it works - if it does not, then exit and become root before logging off and FIX)
(as root) exit (you should be in your account again) sudo su - (you should be root without a passwd, if not, enter and fix /etc/sudoers)
11) NOW... IF you were going to LOAD ANOTHER OPERATING SYSTEM ON THIS DISK... you would use the GUI to resize, delete and/or create new partitions.
If this were a Windows 8 system and you wanted to install Windows 7 or XP you'd likely need to remove the 300MB Microsoft boot sector. And perhaps
mount the Windows partition and delete the Windows directory in order to install the older distribution.
What is a better way of dealing with the Microsoft situation on a new device is to simply remove the original hard drive, leaving it intact and
buying or using another drive to install whatever OS you wanted. This is especially helpful if it's a new system and you ever have warranty issues with the hardware.
12) There are four primary partitions available on hard drives. If you are dual booting a system between Windows XP and Linux it might look like this:
/dev/sda1 - Windows XP (NTFS or FAT32) 50GB
/dev/sda2 - FILES (NTFS or FAT32) (the remainder of the disk)
/dev/sda3 - Linux SWAP (at least 1x memory, 2x memory would be better)
/dev/sda4 - LINUX ext4 about 50GB (and create a link in your user account with access to FILES)
(NOTE: if you plan to use Windows 7, or 8 as the Microsoft portion, then you will need to use Extended disk partition to make this work as
Microsoft uses a 300MB boot partition that takes a primary partition, although you might be able to put the boot and main Microsoft on an Extended ... YMMV)
(NOTE: IF the disk is encrypted dual booting becomes much more complex, or even impossible. Better to use TWO drives, if possible)
Gparted general setup and use
IMG_2020c-CD-based-Gparted-1-2014-12-02.jpg
IMG_2021c-defaults-Gparted-2-2014-12-02.jpg
IMG_2022c-defaults-33-Gparted-3-2014-12-02.jpg
IMG_2023c-defaults-0-for-X-Gparted-4-2014-12-02.jpg
IMG_2024c-Gparted-primary-drive-5-2014-12-02.jpg
IMG_2025c-Gparted-open-TERMINAL-6-2014-12-02.jpg
IMG_2026c-Gparted-ChangeTermColors-7-2014-12-02.jpg
IMG_2027c-Gparted-sudo-su-fdisk-l-8-2014-12-02.jpg
IMG_2028c-Gparted-mkdir-a-mount-9-2014-12-02.jpg
IMG_2029c-Gparted-mkdir-b-mount-10-2014-12-02.jpg
IMG_2030c-grep-df-h-Gparted-11-2014-12-02.jpg
IMG_2031c-alias-ll-Gparted-12-2014-12-02.jpg
IMG_2032c-Gparted-ck-fstab-13-2014-12-02.jpg
if you need to rescue the system because of a lost or forgotten paswd then edit the shadow file... make a backup copy of all files edited first.
JohnMeister.com Today's Date:
|