Ajitabh Pandey's Soul & Syntax

Exploring systems, souls, and stories – one post at a time

Tag: FreeBSD

  • Time-zone Setting in Linux and BSDs from Shell

    Often the default time-zone in a linux and bsd system does not match our preferences. On a system which we have installed ourself, we may have selected the appropriate time-zone during installation, but as systems administrators we often get our hands on a system which is pre-installed and after taking over we want to change the time-zone to something which we are comfortable understanding and co-relating various system events in the time of our comfort.

    The time-zone of  the system is determined by a file called “/etc/localtime”, which a binary file. In order to change the time-zone, we need to replace this file with an appropriate file of our time-zone. All time-zone files are found in “/usr/share/zoneinfo”.

    On some systems “/etc/localtime” is a copy and in some cases a hard link of one of the time-zone found in “/usr/share/zoneinfo” directory. In OpenBSD, “/etc/localtime” is a symlink to one of the files in “/usr/share/zoneinfo”. I prefer the symlink approach, you can pick any of the methods to make appropriate “/etc/localtime” file available.

    In order to change the time-zone of my system from UTC to IST, I did the following.

    $ sudo ln -sf/usr/share/zoneinfo/Asia/Kolkata /etc/localtime

    In case you accidentally delete the “/etc/localtime” file, the timezone of the system reverts to UTC and upon having the correct file present again, it will reflect the correct timezone again. See below (I did this on a RHEL 6 machine) –

    $ date
    Wed Dec 18 13:56:05 IST 2013
    $ sudo rm -f /etc/localtime
    $ date
    Wed Dec 18 08:36:29 UTC 2013
    $ ls -l /etc/localtime
    ls: cannot access /etc/localtime: No such file or directory
    $ sudo ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
    $ date
    Wed Dec 18 14:07:03 IST 2013

     

  • FreeBSD 9.1 on Thinkpad T420

    beastieVery recently I was thinking of trying FreeBSD operating system on a laptop as a desktop system. FreeBSD is an excellent UNIX class of operating systems primarily used as a server on internet. Among other things the operating system posses excellent memory management features, ZFS and LLVM etc.

    I have installed various BSD class of operating systems earlier also, but when I installed FreeBSD 9.1 this time, I noticed that the default disk partitioning options have changed in the installer. By default if the automatic partitioning option is chosen, FreeBSD creates GPT (GUID Partition Table). I decided to proceed with all default options except the timezone settings were changed to IST.

    At the end of the install, the system refused to boot from the hard disk. I thought this is because the BIOS may be configured to use the UEFI (Unified Extensible Firmware Interface) being configured in BIOS as the laptop had windows 7 installed in it. I tried changing the setting to – disable, EUFI/legacy, legacy – but still the laptop did not boot. Upon my research on the internet I came across – https://wiki.freebsd.org/UEFI. Here it was mentioned that –

    Partitions not seen. When using GPT, FreeBSD will create a protective MBR. This MBR has one partition entry covering the whole disk. FreeBSD marks this partition active. This causes at least some UEFI implementations to ignore the GPT. To fix this the partition needs to be marked inactive. This should be fixed as of r251588, to be confirmed.

    Running

    fdisk /dev/sda0

    from the live mode in FreeBSD confirmed that there is an MBR partition created and the flag 80 (active) has been set on it. I booted from a linux CD and ran

    fdisk -l /dev/sda0

    to confirm that this is indeed the case. So I used linux fdisk to remove the active flag (toggle option), but this did not help me.

    At this moment I decided to drop this issue here and take the easy way out in order to get the operating system installed. During the installation this time I chose manual partitioning –

    • deleted all partition
    • changed the partitioning scheme to MBR (the default was GPT)
    • created a FreeBSD partition on it with further two partitions (slices) within the FreeBSD disk area
      • one as type freebsd-swap
      • other freebsd-ufs (mounted at /).

    During the end of the installation an option to go to shell for additional installation is provided. I selected that option and then ran the

    sysinstall

    utility and selected options as follows –

    sysinstall -> Configure -> Packages -> FTP -> Main Site

    Selected all the desired software and finished the installation. The reboot took me straight to FreeBSD.

    Enabling UTF-8

    The available locales can be checked using the locale command. In order to find out the UTF-8 locale which are installed –

    # locale -a | grep UTF-8|grep US
    en_US.UTF-8

    In order to add the support for this locale, following lines need to be added in /etc/login.conf –

    :charset=UTF-8:\
    :lang=en_US.UTF-8:

    Finally run the –

    #cap_mkdb /etc/login.conf

    Now in order to use these following two environment variables can be set –

    LANG=en_US.UTF-8
    GDM_LANG=en_US.UTF-8

    Installing X windows and Windows Managers

    Since I wanted to get a graphical desktop on the laptop, I need to install X windows, a window manager and some other graphical tools like browser etc.

    # pkg_add -r x11 ratpoison awesome stumpwm firefox

    Configuring X and starting is done as below –

    # X -configure
    # cp /root/xorg.conf.new /etc/xorg.conf
    # cat ~/.xinitrc
    export LC_ALL=en_US.UTF-8
    export LANGUAGE=en_US.UTF-8
    export LANG=en_US.UTF-8
    exec /usr/local/bin/ratpoison

    Following two lines needs to be added to

    /etc/rc.conf

    for the X to work correctly –

    hald_enable="YES"
    dbus_enable="YES"

    and then finally

    startx

    to launch the X. May be later on I will install one of the display managers to facilitate graphical login.

    So I am ON with freebsd and now I can start learning/exploring this further and may be try some of the other BSDs along with this as multiboot. I have not really worked on BSDs from quite sometime. I expect this to be a good refresher.