You are not logged in.

#1 2015-03-06 14:48:33

AcousticBruce
Member
Registered: 2015-03-03
Posts: 64

[SOLVED] Deleting partitions, yet still they exist.

My goal here is to get a basic skeleton understanding (without going to deep right now). I have questions about mounting, partitions, the linux environment and what happened at chroot.
I am going to start a fresh Virtual Box so that there is no issues with previous partitions or mounts.

 
# fdisk -l | grep sd

I see one disk ready to partition. ...sda 20.5 GiB

# cfdisk

It now asks me what type of partition label gpt, sun, dos, sgi.
and since I am not booting with the bios of my laptop, I am thinking it doesn't matter in terms of VirtualBox. So I will just pick dos. (correct if I am wrong)
I go ahead and make 3 partitions (not too much rhyme or reason for the sizes).
10Gib Bootable
1Gib linux-swap
9.5Gib

I then write the file system and type yes....

# fdisk -l | grep sd

I have 3 partitions.
sda1 - bootable linux
sda2 - swap
sda3 - linux
looks good so far....

# mkfs.ext4 /dev/sda1
# mkfs.ext4 /dev/sda1
# mkswap /dev/sda2
# swapon /dev/sda2
# mount /dev/sda1 /mnt

It is my understanding that at this time sda* are all blank file system partitions.
***Where does this /mnt folder come from? Is it being created here? Am I just attaching the sda1 partition to the live Arch Linux /mnt directory?
***What are all these folders in the root / directory? Where are they? Are they in RAM? If I loaded this on a blank hard drive from Dos instead of VirtualBox where would this root folder access come from?




Even though I have gotten as far as chroot previously (not in this example). I still delete the partitions and start over for the purpose of learning. So I am going to start over without the need of resetting VirtualBox

lets just do cfdisk and delete everything. And for the hell of it I am going to creat sda1 as swap and sda2 as root folder. Only 2 partitions this time.

# fdisk -l | grep sd

looks right to me... seems to be fresh. Unless I am missing something.

# mkfs.ext4 /dev/sda2

outputs: /dev/sda2 contains a swap file system.
proceed anyway?

# mkswap /dev/sda1

outputs: /dev/sda1 is mounted; will not make swapspace

*** why does sda2 contain a swap file system when I used cfdisk and deleted it?
*** why is sda1 still mounted even though I deleted it. And why did it not prompt me during delete? Since cfdisk when ahead and deleted it, shouldn't the mount vanish?
yes i have seen "dd if=/dev/zero of=/dev/sda bs=512 count=1 conv=notrunc" but that is so advanced I have NO idea whats gong on there. Perhaps a more manual way to do it?

**********
Edit: I am looking up the dd command and reading about what all that means up there... its not as confusing as I thought, but I still have the same questions>
**********


What about unmounting?

# umount /dev/sda1 /mnt

It says unmount:  /mnt  : not mounted.

Hmmm... Am I missing something here? Well this is the point when I delete and recreate a new VB with Arch Linux (only current way I know how to start fresh).


Thank you guys for all your patience and support smile

Last edited by AcousticBruce (2015-05-22 19:19:05)

Offline

#2 2015-03-06 15:42:23

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] Deleting partitions, yet still they exist.

That is one long post -- you might even consider breaking it up into sections (there's also BBCode for lists and stuff, instead of those ***). I'll try to answer all (groups of) questions.

AcousticBruce wrote:

It now asks me what type of partition label gpt, sun, dos, sgi.
and since I am not booting with the bios of my laptop, I am thinking it doesn't matter in terms of VirtualBox. So I will just pick dos. (correct if I am wrong)

That's the safest choice. I would expect VirtualBox to handle at least gpt as well, but that doesn't matter now.

It is my understanding that at this time sda* are all blank file system partitions.
***Where does this /mnt folder come from? Is it being created here? Am I just attaching the sda1 partition to the live Arch Linux /mnt directory?
***What are all these folders in the root / directory? Where are they? Are they in RAM? If I loaded this on a blank hard drive from Dos instead of VirtualBox where would this root folder access come from?

Yes, those directories (including /mnt) are part of the live iso. Running mount or findmnt should show you what's mounted where, including the root filesystem at /. You are mounting the root for you new installation at /mnt and then you can chroot into it.

*** why does sda2 contain a swap file system when I used cfdisk and deleted it?
*** why is sda1 still mounted even though I deleted it. And why did it not prompt me during delete? Since cfdisk when ahead and deleted it, shouldn't the mount vanish?

cfdisk only manipulates the partition table. You have overwritten your first partition table, but you haven't undone everything that mkswap/mkfs.ext4 did. The partition table will be used when mounting a partition and probably not after that, so you may be able to use the old partition (through its mountpoint) as long as it's mounted. And using cfdisk again to create a partition table identical to the original (the one with three partitions, including the one that's still mounted) would get you back to before you "deleted" the partitions. I'm not sure this is entirely riskfree and it is tricky anyway. Normally you want to unmount the old partitions before making changes.

What about unmounting?

# umount /dev/sda1 /mnt

It says unmount:  /mnt  : not mounted.

Hmmm... Am I missing something here?

You tried to unmount twice. If you look at the man page, you'll see umount can take a list of devices and directories. If a device is mounted on only one directory, supplying the device name will work. That is what happened here: /dev/sda1 is mounted on /mnt, so umount, when seeing the argument '/dev/sda1', unmounted that device from /mnt. Then it tried to process the second argument ('/mnt'), but nothing was mounted there anymore, so it failed.

Last edited by Raynman (2015-03-06 15:45:27)

Offline

#3 2015-03-06 16:12:03

EscapedNull
Member
Registered: 2013-12-04
Posts: 129

Re: [SOLVED] Deleting partitions, yet still they exist.

Partitions are just sections of the physical drive. They span between a start and end boundary, addressed by a sector number, which is the smallest addressable unit of data on a physical disk (512 bytes). The partition table stores a list of partition numbers and their boundaries, along with some metadata. Deleting a partition from the partition table doesn't touch the data in that partition, it just causes the system to see the sectors previously assigned to the partition now as free space. If you recreate the partition with the same boundaries, the data will still be there as you left it. The partition table type is just one of the standard formats for storing the boundaries and metadata. DOS format is being deprecated in favor of GPT for newer systems.

Filesystems do write data inside the partition. Strictly speaking, a filesystem can be created on any block device. A block device just stores raw bytes, used by the filesystem to represent files. A partition is an example of a block device, e.g. /dev/sda1. mkfs initializes a filesystem on a given block device. mount takes a block device and a mountpoint, and makes the root directory of the filesystem on the given block device available under the given directory (mountpoint) on the real root filesystem (the kernel's root= parameter). In other words, mount turns a block device into an accessible filesystem.

In this case, the real root filesystem resides on your USB drive (probably /dev/sdb*). When you mount /dev/sda1 on /mnt, any file paths beginning with /mnt are sent to the corresponding directory in the filesystem located on /dev/sda1. Running mount with no arguments will show you all mountpoints on the system, along with their underlying block devices.

If you're coming from Windows, the filesystem hierarchy concept can be hard to grasp at first. In Windows, every device has its own "mountpoint" (so to speak) located above any filesystem's root directory, e.g. C:/ and D:/ are separate filesystems. GNU/Linux/Unix uses a similar concept, but there is only one root directory on the whole machine, and other filesystems are mounted under it. Although it was simple once I understood it, I actually had trouble learning this concept when I first started using Linux.

Trivia: Some filesystems, like /sys, don't have an underlying block device at all. These are simply a way for the kernel to communicate with programs using the filesystem API, even though the data isn't "stored" anywhere.

Sorry if I misunderstood your question. Hopefully this post helps you understand the basics.

Offline

#4 2015-03-06 18:14:22

MoonSwan
Member
From: Great White North
Registered: 2008-01-23
Posts: 881

Re: [SOLVED] Deleting partitions, yet still they exist.

@OP, Slightly off-topic:  do not rely on the "cfdisk" program.  It is ancient, un-maintained and generally a bad tool to use because, for one example, it doesn't understand modern partition boundaries on newer hard drives.  Try to learn to use "gdisk" or, if you really want a graphical front-end to learn on, "cgdisk."  Also do not try to use "sgdisk."  It's purpose is as a disk management program to be used with scripts and automated system management. 

This is all in my own opinion, of course, and I learned about gdisk from the Arch wiki and some related links to the author of gdisk's website.

Offline

#5 2015-03-06 19:01:17

AcousticBruce
Member
Registered: 2015-03-03
Posts: 64

Re: [SOLVED] Deleting partitions, yet still they exist.

This has all made things clearer! All of it! Thank you all.

ExcapedNull, you really helped me understand mounting and partitions vs file systems.


MoonSwan.... No. I am not tied to that, I just do not know most things in Linux. So basically I am learning gdisk now...

Offline

Board footer

Powered by FluxBB