Hi Everyone,
I've read some threads on this forum and found some good hints already :)
I'm having trouble writing a script and would appreciate all input, advice, info, or tips.
I'd like to write a script that does the following;
- identifies current recognized partitions
- flags those with System=Linux
- Identifies these 'Linux' partitions (filesystems) as type (ext2, ext3, reiserfs, jfs, xfs)
- IF the type is reiserfs associate that partition to next available loop device file
- mount that reiserfs partition to mount point
Where am I at right now? Well, I know how to find the partitions;
'fdisk -l'
And that output shows the 'System' field, and those marked 'Linux' are entries I'm only concerned with.
I know the mount command may be used to guess the Linux filesystem type via;
'mount -f --guess-fstype /dev/XXX'
('-f' means to just act like it's doing it, but don't.) I know then if anything is returned as 'reiserfs' I want to know, because I then want to associate any reiserfs filesystem (partition) to a loop device file;
'losetup -f'
Shows me next available loop device
'losetup /dev/loopXXX /dev/reiserfs_partition_here'
This associates the reiserfs partition to the loop device XXX.
I then use 'mount' again;
'mount /dev/loopXXX /mnt/mnt_point'
I'm not really sure where to begin though. I've written very simple bash scripts, but nothing complicated. I've been hacking away at this one, but haven't found a solution just yet. Any thoughts on a systematic approach to what I'm trying to accomplish?
'fdisk -l | grep dev | grep Linux'
Is a start, because it returns output similar to;
[root@root mnt]# fdisk -l | grep -w dev | grep Linux
/dev/scsi/host2/bus0/target0/lun0/part1 1 196 98264+ 83 Linux
/dev/scsi/host2/bus0/target0/lun0/part4 589 1020 216648 83 Linux
/dev/ide/host0/bus1/target0/lun0/part2 17441 17745 153720 83 Linux
Now, from those I can't see to run my 'mount -f --guess-fstype' against each one of them?
That's my next step, I think?
kind regards,
-lt